Skip to content

Commit 81de9ac

Browse files
committed
[TASK] Assert result based on symfony version in deprecated code tests
Symfony 7 removed deprecated code paths [1][2] and therefore started using strict `in_array()` check for the `in` and `notIn` condition in the expression language. With #102746 the usage of symfony 7 has been allowed, which itself introduces breaking changes. It is optional to upgrade to symfony 7 and therefore breaking changes has been respected and excludes from the TYPO3 policies regarding breaking changes as it is not enforced. This change modifies two tests to assert results based on the used symfony version. [1] symfony/symfony#50867 [2] symfony/symfony@7050bc82dd25c540958 Resolves: #102766 Related: #102746 Releases: 12.4 Change-Id: I0624f33ff270ba793054d0ff84810beee1a98c06 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82358 Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Stefan Bürk <stefan@buerk.tech>
1 parent 822eb0e commit 81de9ac

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

typo3/sysext/backend/Tests/FunctionalDeprecated/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,21 @@ public function treeLevelConditionDoesNotMatchFaultyValue(): void
230230
public function PIDupinRootlineConditionMatchesSinglePageIdInRootline(): void
231231
{
232232
$subject = $this->getConditionMatcher(3);
233+
234+
if (!$this->isSymfonySeven()) {
235+
// Before Symfony 7+ everything was chaos.
236+
self::assertTrue($subject->match('[2 in tree.rootLineParentIds]'));
237+
self::assertTrue($subject->match('["2" in tree.rootLineParentIds]'));
238+
self::assertTrue($subject->match('[\'2\' in tree.rootLineParentIds]'));
239+
return;
240+
}
241+
242+
// Symfony 7 removed deprecated code paths and therefore started using strict `in_array()` check for the
243+
// `in` and `notIn` condition in the expression language. Basically this is a breaking change in regard
244+
// for TYPO3 users, but as the use of symfony 7 is the choice for project it's reasonable to live with it.
233245
self::assertTrue($subject->match('[2 in tree.rootLineParentIds]'));
234-
self::assertTrue($subject->match('["2" in tree.rootLineParentIds]'));
235-
self::assertTrue($subject->match('[\'2\' in tree.rootLineParentIds]'));
246+
self::assertFalse($subject->match('["2" in tree.rootLineParentIds]'));
247+
self::assertFalse($subject->match('[\'2\' in tree.rootLineParentIds]'));
236248
}
237249

238250
/**
@@ -440,4 +452,14 @@ protected function setUpWorkspaceAspect(int $workspaceId): void
440452
{
441453
GeneralUtility::makeInstance(Context::class)->setAspect('workspace', new WorkspaceAspect($workspaceId));
442454
}
455+
456+
private function isSymfonySeven(): bool
457+
{
458+
// Symfony 7 dropped the `inArray` method with 7.0.0 from the BinaryNode, so we can use it as a check here for
459+
// the version and avoid to deal with composer version information here.
460+
return method_exists(
461+
\Symfony\Component\ExpressionLanguage\Node\BinaryNode::class,
462+
'inArray'
463+
) === false;
464+
}
443465
}

typo3/sysext/frontend/Tests/FunctionalDeprecated/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,21 @@ public function treeLevelConditionDoesNotMatchFaultyValue(): void
270270
public function PIDupinRootlineConditionMatchesSinglePageIdInRootline(): void
271271
{
272272
$subject = $this->getConditionMatcher();
273+
274+
if (!$this->isSymfonySeven()) {
275+
// Before Symfony 7+ everything was chaos.
276+
self::assertTrue($subject->match('[2 in tree.rootLineParentIds]'));
277+
self::assertTrue($subject->match('["2" in tree.rootLineParentIds]'));
278+
self::assertTrue($subject->match('[\'2\' in tree.rootLineParentIds]'));
279+
return;
280+
}
281+
282+
// Symfony 7 removed deprecated code paths and therefore started using strict `in_array()` check for the
283+
// `in` and `notIn` condition in the expression language. Basically this is a breaking change in regard
284+
// for TYPO3 users, but as the use of symfony 7 is the choice for project it's reasonable to live with it.
273285
self::assertTrue($subject->match('[2 in tree.rootLineParentIds]'));
274-
self::assertTrue($subject->match('["2" in tree.rootLineParentIds]'));
275-
self::assertTrue($subject->match('[\'2\' in tree.rootLineParentIds]'));
286+
self::assertFalse($subject->match('["2" in tree.rootLineParentIds]'));
287+
self::assertFalse($subject->match('[\'2\' in tree.rootLineParentIds]'));
276288
}
277289

278290
/**
@@ -623,4 +635,14 @@ protected function setupFrontendController(int $pageId): void
623635
2 => ['uid' => 3, 'pid' => 2],
624636
];
625637
}
638+
639+
private function isSymfonySeven(): bool
640+
{
641+
// Symfony 7 dropped the `inArray` method with 7.0.0 from the BinaryNode, so we can use it as a check here for
642+
// the version and avoid to deal with composer version information here.
643+
return method_exists(
644+
\Symfony\Component\ExpressionLanguage\Node\BinaryNode::class,
645+
'inArray'
646+
) === false;
647+
}
626648
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy