Skip to content

Commit

Permalink
fix(v12): use typo3 12
Browse files Browse the repository at this point in the history
  • Loading branch information
twojtylak committed Jul 1, 2024
1 parent 7f3e1f6 commit 207ad07
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Classes/Database/Query/Restriction/SiteRestriction.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private function getSitePids(): array
return [];
}

$this->cachedSitePids = $this->pageRepository->getPageIdsRecursive($site->getRootPageId(), 999);
$this->cachedSitePids = $this->pageRepository->getPageIdsRecursive([$site->getRootPageId()], 999);

return $this->cachedSitePids;
}
Expand Down
7 changes: 6 additions & 1 deletion Classes/Middleware/TypoScriptFrontendInitialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public function __construct(Context $context)
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$tsfe = $this->getTyposcriptFrontendController($request);
$tsfe->determineId();

try {
$tsfe->determineId($request);
} catch (\Exception $e) {
// v12: not sure if the `determineId` call is still necessary in v12
}

return $handler->handle($request);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Acceptance/Api.suite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class_name: ApiTester
actor: ApiTester
modules:
enabled:
- Asserts
Expand Down
2 changes: 1 addition & 1 deletion Tests/Acceptance/Support/Helper/ApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ApiAccess extends Module
{
protected $requiredFields = ['grant_type', 'client_id', 'client_secret'];
protected array $requiredFields = ['grant_type', 'client_id', 'client_secret'];

public function grabValidCredentials(): array
{
Expand Down
22 changes: 18 additions & 4 deletions Tests/Unit/Middleware/LanguageResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ public function it_will_set_language_by_href_lang(): void
->method('setAspect')
->with('language', self::isInstanceOf(LanguageAspect::class));

$requestMock->expects(self::exactly(2))
$matcher = self::exactly(2);

$requestMock->expects($matcher)
->method('withAttribute')
->withConsecutive(['context', $this->contextMock], ['language', $siteLanguageMock])
->willReturnCallback(function (string $key, string $value) use ($matcher, $siteLanguageMock) {
match ($matcher->numberOfInvocations()) {
1 => $this->assertEquals(['context', $this->contextMock], [$key, $value]),
2 => $this->assertEquals(['language', $siteLanguageMock], [$key, $value]),
};
})
->willReturn($requestMock);

$this->subject->process($requestMock, $requestHandlerMock);
Expand Down Expand Up @@ -208,9 +215,16 @@ public function it_will_set_language_by_two_letter_iso_code(): void
->method('setAspect')
->with('language', self::isInstanceOf(LanguageAspect::class));

$requestMock->expects(self::exactly(2))
$matcher = self::exactly(2);

$requestMock->expects($matcher)
->method('withAttribute')
->withConsecutive(['context', $this->contextMock], ['language', $siteLanguageMock])
->willReturnCallback(function (string $key, string $value) use ($matcher, $siteLanguageMock) {
match ($matcher->numberOfInvocations()) {
1 => $this->assertEquals(['context', $this->contextMock], [$key, $value]),
2 => $this->assertEquals(['language', $siteLanguageMock], [$key, $value]),
};
})
->willReturn($requestMock);

$this->subject->process($requestMock, $requestHandlerMock);
Expand Down
11 changes: 9 additions & 2 deletions Tests/Unit/Middleware/TypoScriptFrontendInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ public function it_will_init_typoscript_frontend_on_process(): void
$frontendControllerMock = $this->createMock(TypoScriptFrontendController::class);
GeneralUtility::addInstance(TypoScriptFrontendController::class, $frontendControllerMock);

$requestMock
$matcher = self::exactly(3);

$requestMock->expects($matcher)
->method('getAttribute')
->withConsecutive(['site'], ['language'])
->willReturnCallback(function (string $key, string $value) use ($matcher, $siteLanguageMock) {
match ($matcher->numberOfInvocations()) {
1 => $this->assertEquals('site', $value),
2 => $this->assertEquals('language', $value),
};
})
->willReturnOnConsecutiveCalls($siteMock, $pageArgumentsMock, $siteLanguageMock);

$this->subject->process($requestMock, $requestHandlerMock);
Expand Down
1 change: 1 addition & 0 deletions Tests/codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ paths:
tests: Acceptance
data: .
log: ../.Build/Web/typo3temp/var/tests/AcceptanceReports
output: ./.Build/Web/typo3temp/var/tests/_output
support: Acceptance/Support
settings:
colors: true
Expand Down
21 changes: 13 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
"description": "TYPO3 REST API Framework",
"type": "typo3-cms-extension",
"license": "GPL-3.0-or-later",
"repositories": [
{
"type": "git",
"url": "https://github.com/toujou/tactician.git"
}
],
"require": {
"php": "^7.4 | ^8",
"php": "^8.1",
"ext-json": "*",
"dfau/convergence": "dev-master",
"typo3/cms-core": "^11.5 | ^12.4",
"dfau/convergence": "v12.x-dev as dev-master",
"typo3/cms-core": "^12.4",
"league/fractal": "~0.18",
"league/tactician": "dev-master",
"nikic/fast-route": "^1.3.0",
Expand All @@ -20,11 +26,10 @@
"roave/security-advisories": "dev-latest",
"dfau/coding-standard": "^2.0",
"typo3/testing-framework": "^7.0.4",
"codeception/codeception": "^4.1",
"codeception/module-rest": "^1.3",
"codeception/module-asserts": "^1.3",
"codeception/module-phpbrowser": "^1.0",
"ssch/typo3-rector": "^v1.0.5"
"codeception/module-phpbrowser": "^3.0",
"codeception/module-asserts": "^3.0",
"codeception/module-rest": "^3.3",
"codeception/codeception": "^5.1"
},
"authors": [
{
Expand Down
3 changes: 1 addition & 2 deletions etc/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ services:
done;
echo Database is up;
php -v | grep '^PHP';
ln -sfn ${ROOT_DIR} Web/typo3conf/ext/toujou_api
mkdir -p Web/typo3temp/var/tests/
COMMAND=\"vendor/codeception/codeception/codecept run Api -d -c Web/typo3conf/ext/toujou_api/Tests/codeception.yml ${TEST_FILE}\"
COMMAND=\"vendor/codeception/codeception/codecept run Api -d -c ${ROOT_DIR}/Tests/codeception.yml ${TEST_FILE}\"
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
$${COMMAND};
Expand Down

0 comments on commit 207ad07

Please sign in to comment.