Skip to content

Commit

Permalink
Update func tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfroemkenjw committed Jan 15, 2024
1 parent 8bd7d01 commit 446a20c
Show file tree
Hide file tree
Showing 6 changed files with 971 additions and 169 deletions.
47 changes: 46 additions & 1 deletion Tests/Functional/Configuration/ExtConfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@

use JWeiland\Checkfaluploads\Configuration\ExtConf;
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -52,6 +56,30 @@ public function tearDown(): void
parent::tearDown();
}

private function getRequestForContext(int $applicationType): ServerRequestInterface
{
$site = new Site('https://example.com', 1, [
'base' => '/',
'languages' => [
0 => [
'languageId' => 0,
'locale' => 'en_US.UTF-8',
'base' => '/en/',
'enabled' => false,
],
],
]);

$this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');

// Request to default page
$request = new ServerRequest('https://example.com', 'GET');
$request = $request->withAttribute('site', $site);
$request = $request->withAttribute('applicationType', $applicationType);

return $request->withAttribute('language', $site->getDefaultLanguage());
}

/**
* @test
*/
Expand Down Expand Up @@ -79,8 +107,25 @@ public function setOwnerSetsOwner(): void
/**
* @test
*/
public function getLabelForUserRightsContainsOwner(): void
public function getLabelForUserRightsInFrontendContextContainsOwner(): void
{
$GLOBALS['TYPO3_REQUEST'] = $this->getRequestForContext(SystemEnvironmentBuilder::REQUESTTYPE_FE);

$this->subject->setOwner('foo bar');

self::assertStringContainsString(
'foo bar',
$this->subject->getLabelForUserRights()
);
}

/**
* @test
*/
public function getLabelForUserRightsInBackendContextContainsOwner(): void
{
$GLOBALS['TYPO3_REQUEST'] = $this->getRequestForContext(SystemEnvironmentBuilder::REQUESTTYPE_BE);

$this->subject->setOwner('foo bar');

self::assertStringContainsString(
Expand Down
9 changes: 9 additions & 0 deletions Tests/Functional/Fixtures/basic_template.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
page = PAGE
page {
config {
disableAllHeaderCode = 1
}

10 = TEXT
10.value = <p>I like apples</p>
}
6 changes: 6 additions & 0 deletions Tests/Functional/Fixtures/pages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<pages>
<uid>1</uid>
</pages>
</dataset>
Loading

0 comments on commit 446a20c

Please sign in to comment.