events/Tests/Functional/Frontend/FilterTest.php
Daniel Siepmann 39dfc0b42a
Add grouping of locations. (#64)
It is now possible to group locations.
Each location can have arbitrary children.

That can be used for editorial structuring.
Filtering for a location will always find all dates where the location
or one of the child locations is assigned.

One use case can be to group imported locations and provide a grouped
location for filtering in frontend.

Relates: #11233
2024-07-24 10:44:34 +02:00

68 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Tests\Functional\Frontend;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use WerkraumMedia\Events\Tests\Functional\AbstractFunctionalTestCase;
class FilterTest extends AbstractFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SiteStructure.php');
$this->setUpFrontendRendering();
}
#[Test]
public function canFilterByASingleLocationViaFlexform(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FilterByASingleLocationViaFlexform.php');
$request = new InternalRequest('https://example.com/');
$request = $request->withPageId(1);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
$html = (string)$response->getBody();
self::assertStringNotContainsString('Lotte in Weimar', $html);
self::assertStringContainsString('Was hat das Universum mit mir zu tun?', $html);
}
#[Test]
public function canFilterByTwoLocationsViaFlexform(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FilterByTwoLocationsViaFlexform.php');
$request = new InternalRequest('https://example.com/');
$request = $request->withPageId(1);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
$html = (string)$response->getBody();
self::assertStringContainsString('Lotte in Weimar', $html);
self::assertStringContainsString('Was hat das Universum mit mir zu tun?', $html);
}
#[Test]
public function canFilterDatesByParentLocationViaFlexform(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FilterDatesByParentLocationViaFlexform.php');
$request = new InternalRequest('https://example.com/');
$request = $request->withPageId(1);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
$html = (string)$response->getBody();
self::assertStringContainsString('Lotte in Weimar', $html);
self::assertStringContainsString('Was hat das Universum mit mir zu tun?', $html);
}
}