Skip to content

Commit

Permalink
[TASK] Add quality stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ayacoo committed May 1, 2024
1 parent 7f4e4cd commit 6448830
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Tests/Functional/Service/Fixtures/pages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"pages"
,"uid","pid","title","slug","sys_language_uid"
,1,0,"Home","/",0
3 changes: 3 additions & 0 deletions Tests/Functional/Service/Fixtures/sys_redirect.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"sys_redirect"
,"uid","source_host","source_path","target","target_statuscode","force_https"
,1,"*","/test","t3://page?uid=1",301,1
48 changes: 48 additions & 0 deletions Tests/Functional/Service/RedirectDemandServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
namespace Ayacoo\Tiktok\Tests\Functional\Service;

use Ayacoo\RedirectTab\Service\RedirectDemandService;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Configuration\Event\SiteConfigurationBeforeWriteEvent;
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

final class RedirectDemandServiceTest extends FunctionalTestCase
Expand All @@ -31,4 +35,48 @@ public function getRedirectsReturnsPerDefaultAnEmptyArray(): void

self::assertCount(0, $result);
}

/**
* @test
*/
public function getRedirectsReturnsArray(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');
$this->importCSVDataSet(__DIR__ . '/Fixtures/sys_redirect.csv');

$identifier = 'website-local';
$configuration = [
'rootPageId' => 1,
'base' => 'http://example.com/',
];


$event = new SiteConfigurationBeforeWriteEvent($identifier, $configuration);
$eventDispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
$eventDispatcherMock->expects(self::once())->method('dispatch')->with(self::anything())->willReturn($event);

$siteConfiguration = new SiteConfiguration(
$this->instancePath . '/typo3conf/sites/',
$eventDispatcherMock
);

try {
$siteConfiguration->write($identifier, $configuration);
} catch (\Exception $exception) {
self::markTestSkipped($exception->getMessage());
}

$siteFinder = new SiteFinder();
$site = $siteFinder->getSiteByPageId(1);

$data = [];
$data['site'] = $site;
$data['databaseRow']['sys_language_uid'] = 0;
$data['effectivePid'] = 1;

$this->subject->setData($data);
$result = $this->subject->getRedirects(1);

self::assertCount(1, $result);
}
}

0 comments on commit 6448830

Please sign in to comment.