Skip to content

Commit 0c243ad

Browse files
committed
[TASK] Add TYPO3 v14 support
1 parent 2e7625e commit 0c243ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+435
-203
lines changed

Build/UnitTestsBootstrap.php

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<?php
22

3+
use TYPO3\CMS\Core\Cache\Backend\NullBackend;
4+
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
5+
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
6+
use TYPO3\CMS\Core\Core\Bootstrap;
7+
use TYPO3\CMS\Core\Core\Environment;
8+
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
9+
use TYPO3\CMS\Core\Package\Cache\PackageCacheInterface;
10+
use TYPO3\CMS\Core\Package\PackageManager;
11+
use TYPO3\CMS\Core\Package\UnitTestPackageManager;
12+
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
13+
use TYPO3\CMS\Core\Utility\GeneralUtility;
14+
use TYPO3\TestingFramework\Core\Testbase;
15+
316
/*
417
* This file is part of the TYPO3 CMS project.
518
*
@@ -12,7 +25,6 @@
1225
*
1326
* The TYPO3 project - inspiring people to share!
1427
*/
15-
1628
/**
1729
* Boilerplate for a unit test phpunit boostrap file.
1830
*
@@ -28,7 +40,7 @@
2840
* adapt to extensions needs.
2941
*/
3042
(static function () {
31-
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
43+
$testbase = new Testbase();
3244

3345
// These if's are for core testing (package typo3/cms) only. cms-composer-installer does
3446
// not create the autoload-include.php file that sets these env vars and sets composer
@@ -46,40 +58,40 @@
4658

4759
$testbase->defineSitePath();
4860

49-
$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
61+
$requestType = SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI;
5062
\TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, $requestType);
5163

52-
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext');
53-
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets');
54-
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests');
55-
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient');
64+
$testbase->createDirectory(Environment::getPublicPath() . '/typo3conf/ext');
65+
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/assets');
66+
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/tests');
67+
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/transient');
5668

5769
// Retrieve an instance of class loader and inject to core bootstrap
5870
$classLoader = require $testbase->getPackagesPath() . '/autoload.php';
59-
\TYPO3\CMS\Core\Core\Bootstrap::initializeClassLoader($classLoader);
71+
Bootstrap::initializeClassLoader($classLoader);
6072

6173
// Initialize default TYPO3_CONF_VARS
62-
$configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
74+
$configurationManager = new ConfigurationManager();
6375
$GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();
6476

65-
$cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend(
77+
$cache = new PhpFrontend(
6678
'core',
67-
new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
79+
new NullBackend('production', [])
6880
);
6981

7082
// Set all packages to active
71-
if (interface_exists(\TYPO3\CMS\Core\Package\Cache\PackageCacheInterface::class)) {
72-
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, \TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache));
83+
if (interface_exists(PackageCacheInterface::class)) {
84+
$packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, Bootstrap::createPackageCache($cache));
7385
} else {
7486
// v10 compatibility layer
7587
// @deprecated Will be removed when v10 compat is dropped from testing-framework
76-
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, $cache);
88+
$packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, $cache);
7789
}
7890

79-
\TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
80-
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);
91+
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
92+
ExtensionManagementUtility::setPackageManager($packageManager);
8193

8294
$testbase->dumpClassLoadingInformation();
8395

84-
\TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
96+
GeneralUtility::purgeInstances();
8597
})();

Build/phpstan-baseline.neon

Lines changed: 218 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,235 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#"
4+
message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#'
5+
identifier: method.notFound
56
count: 1
67
path: ../Classes/Controller/Cart/OrderController.php
78

89
-
9-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:getTaxClass\\(\\)\\.$#"
10+
message: '#^Instanceof between Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface and Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface will always evaluate to true\.$#'
11+
identifier: instanceof.alwaysTrue
12+
count: 1
13+
path: ../Classes/Domain/Model/Cart/BeVariant.php
14+
15+
-
16+
message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:getTaxClass\(\)\.$#'
17+
identifier: method.notFound
1018
count: 2
1119
path: ../Classes/Domain/Model/Cart/Cart.php
1220

1321
-
14-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:setCart\\(\\)\\.$#"
22+
message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:setCart\(\)\.$#'
23+
identifier: method.notFound
1524
count: 1
1625
path: ../Classes/Domain/Model/Cart/Cart.php
1726

1827
-
19-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#"
28+
message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#'
29+
identifier: method.notFound
2030
count: 1
2131
path: ../Classes/EventListener/Order/Finish/ClearCart.php
32+
33+
-
34+
message: '#^Method TYPO3\\CMS\\Form\\Mvc\\Persistence\\FormPersistenceManagerInterface\:\:listForms\(\) invoked with 1 parameter, 2 required\.$#'
35+
identifier: arguments.count
36+
count: 1
37+
path: ../Classes/Hooks/FormDefinitions.php
38+
39+
-
40+
message: '#^Parameter \$cacheManager of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\CacheManager\.$#'
41+
identifier: class.notFound
42+
count: 1
43+
path: ../Classes/Hooks/ItemsProcFunc.php
44+
45+
-
46+
message: '#^Parameter \$resourceFactory of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\ResourceFactory\.$#'
47+
identifier: class.notFound
48+
count: 1
49+
path: ../Classes/Hooks/ItemsProcFunc.php
50+
51+
-
52+
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager has unknown class Extcode\\Cart\\Hooks\\CacheManager as its type\.$#'
53+
identifier: class.notFound
54+
count: 1
55+
path: ../Classes/Hooks/ItemsProcFunc.php
56+
57+
-
58+
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager is never read, only written\.$#'
59+
identifier: property.onlyWritten
60+
count: 1
61+
path: ../Classes/Hooks/ItemsProcFunc.php
62+
63+
-
64+
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory has unknown class Extcode\\Cart\\Hooks\\ResourceFactory as its type\.$#'
65+
identifier: class.notFound
66+
count: 1
67+
path: ../Classes/Hooks/ItemsProcFunc.php
68+
69+
-
70+
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory is never read, only written\.$#'
71+
identifier: property.onlyWritten
72+
count: 1
73+
path: ../Classes/Hooks/ItemsProcFunc.php
74+
75+
-
76+
message: '#^Attribute class TYPO3\\CMS\\Install\\Attribute\\UpgradeWizard is deprecated\: since v14\.0, will be removed in TYPO34 v15\.0\. Use \\TYPO3\\CMS\\Core\\Attribute\\UpgradeWizard instead\.$#'
77+
identifier: attribute.deprecated
78+
count: 1
79+
path: ../Classes/Updates/ExtcodeCartCTypeMigration.php
80+
81+
-
82+
message: '''
83+
#^Class Extcode\\Cart\\Updates\\ExtcodeCartCTypeMigration extends deprecated class TYPO3\\CMS\\Install\\Updates\\AbstractListTypeToCTypeUpdate\:
84+
since v14\.0, will be removed in TYPO34 v15\.0\. Use \\TYPO3\\CMS\\Core\\Upgrades\\AbstractListTypeToCTypeUpdate instead\.$#
85+
'''
86+
identifier: class.extendsDeprecatedClass
87+
count: 1
88+
path: ../Classes/Updates/ExtcodeCartCTypeMigration.php
89+
90+
-
91+
message: '#^Loose comparison using \!\= between non\-empty\-string and '''' will always evaluate to true\.$#'
92+
identifier: notEqual.alwaysTrue
93+
count: 1
94+
path: ../Classes/Validation/Validator/EmptyValidator.php
95+
96+
-
97+
message: '#^Access to constant on deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#'
98+
identifier: classConstant.deprecatedClass
99+
count: 1
100+
path: ../Classes/ViewHelpers/IncludeFileViewHelper.php
101+
102+
-
103+
message: '#^Call to method sanitize\(\) of deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#'
104+
identifier: method.deprecatedClass
105+
count: 1
106+
path: ../Classes/ViewHelpers/IncludeFileViewHelper.php
107+
108+
-
109+
message: '#^Strict comparison using \!\=\= between '''' and '''' will always evaluate to false\.$#'
110+
identifier: notIdentical.alwaysFalse
111+
count: 1
112+
path: ../Classes/ViewHelpers/TitleTagViewHelper.php
113+
114+
-
115+
message: '#^Variable \$arguments on left side of \?\? is never defined\.$#'
116+
identifier: nullCoalesce.variable
117+
count: 1
118+
path: ../Classes/ViewHelpers/TitleTagViewHelper.php
119+
120+
-
121+
message: '''
122+
#^Call to deprecated method addPiFlexFormValue\(\) of class TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility\:
123+
Will be removed in TYPO3 v15$#
124+
'''
125+
identifier: staticMethod.deprecated
126+
count: 1
127+
path: ../Configuration/TCA/Overrides/tt_content.php
128+
129+
-
130+
message: '''
131+
#^Call to deprecated method disableAutoload\(\) of class PHPUnit\\Framework\\MockObject\\MockBuilder\:
132+
https\://github\.com/sebastianbergmann/phpunit/issues/5309$#
133+
'''
134+
identifier: method.deprecated
135+
count: 1
136+
path: ../Tests/Unit/Domain/Model/Cart/BeVariantTest.php
137+
138+
-
139+
message: '''
140+
#^Call to deprecated method addMethods\(\) of class PHPUnit\\Framework\\MockObject\\MockBuilder\:
141+
https\://github\.com/sebastianbergmann/phpunit/issues/5320$#
142+
'''
143+
identifier: method.deprecated
144+
count: 1
145+
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php
146+
147+
-
148+
message: '''
149+
#^Call to deprecated method disableAutoload\(\) of class PHPUnit\\Framework\\MockObject\\MockBuilder\:
150+
https\://github\.com/sebastianbergmann/phpunit/issues/5309$#
151+
'''
152+
identifier: method.deprecated
153+
count: 1
154+
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php
155+
156+
-
157+
message: '#^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase\.$#'
158+
identifier: method.deprecated
159+
count: 1
160+
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php
161+
162+
-
163+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array will always evaluate to true\.$#'
164+
identifier: staticMethod.alreadyNarrowedType
165+
count: 1
166+
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php
167+
168+
-
169+
message: '#^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase\.$#'
170+
identifier: method.deprecated
171+
count: 1
172+
path: ../Tests/Unit/Domain/Model/Order/AbstractServiceTest.php
173+
174+
-
175+
message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Discount\(\) on a separate line has no effect\.$#'
176+
identifier: new.resultUnused
177+
count: 6
178+
path: ../Tests/Unit/Domain/Model/Order/DiscountTest.php
179+
180+
-
181+
message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Tax\(\) on a separate line has no effect\.$#'
182+
identifier: new.resultUnused
183+
count: 2
184+
path: ../Tests/Unit/Domain/Model/Order/TaxTest.php
185+
186+
-
187+
message: '#^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase\.$#'
188+
identifier: method.deprecated
189+
count: 1
190+
path: ../Tests/Unit/Domain/Model/Product/AbstractProductTest.php
191+
192+
-
193+
message: '''
194+
#^Call to deprecated method getObjectForTrait\(\) of class PHPUnit\\Framework\\TestCase\:
195+
https\://github\.com/sebastianbergmann/phpunit/issues/5244$#
196+
'''
197+
identifier: method.deprecated
198+
count: 1
199+
path: ../Tests/Unit/Domain/Model/Product/CategoryTraitTest.php
200+
201+
-
202+
message: '''
203+
#^Call to deprecated method getObjectForTrait\(\) of class PHPUnit\\Framework\\TestCase\:
204+
https\://github\.com/sebastianbergmann/phpunit/issues/5244$#
205+
'''
206+
identifier: method.deprecated
207+
count: 1
208+
path: ../Tests/Unit/Domain/Model/Product/MeasureTraitTest.php
209+
210+
-
211+
message: '''
212+
#^Call to deprecated method getObjectForTrait\(\) of class PHPUnit\\Framework\\TestCase\:
213+
https\://github\.com/sebastianbergmann/phpunit/issues/5244$#
214+
'''
215+
identifier: method.deprecated
216+
count: 1
217+
path: ../Tests/Unit/Domain/Model/Product/ServiceAttributeTraitTest.php
218+
219+
-
220+
message: '''
221+
#^Call to deprecated method getObjectForTrait\(\) of class PHPUnit\\Framework\\TestCase\:
222+
https\://github\.com/sebastianbergmann/phpunit/issues/5244$#
223+
'''
224+
identifier: method.deprecated
225+
count: 1
226+
path: ../Tests/Unit/Domain/Model/Product/StockTraitTest.php
227+
228+
-
229+
message: '''
230+
#^Call to deprecated method getObjectForTrait\(\) of class PHPUnit\\Framework\\TestCase\:
231+
https\://github\.com/sebastianbergmann/phpunit/issues/5244$#
232+
'''
233+
identifier: method.deprecated
234+
count: 1
235+
path: ../Tests/Unit/Domain/Model/Product/TagTraitTest.php

Build/phpstan.neon

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
includes:
2-
- phpstan-baseline.neon
2+
- 'phpstan-baseline.neon'
3+
34
parameters:
45
level: 4
6+
57
paths:
68
- ../Classes
79
- ../Configuration
810
- ../Tests
911
- ../ext_emconf.php
1012
- ../ext_localconf.php
13+
14+
disallowedFunctionCalls:
15+
-
16+
function:
17+
- 'var_dump()'
18+
- 'xdebug_break()'
19+
message: 'Do not add debugging'
20+
-
21+
function: 'header()'
22+
message: 'Use API instead'
23+
24+
disallowedStaticCalls:
25+
-
26+
method: 'TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()'
27+
message: 'Do not add debugging'
28+
29+
disallowedSuperglobals:
30+
-
31+
superglobal:
32+
- '$_GET'
33+
- '$_POST'
34+
- '$_FILES'
35+
- '$_SERVER'
36+
message: 'Use API instead'

Classes/Controller/Backend/ActionController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
*/
1313

1414
use TYPO3\CMS\Backend\Utility\BackendUtility;
15-
use TYPO3\CMS\Core\Utility\GeneralUtility;
1615
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
16+
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
1717

1818
class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
1919
{
2020
protected array $pluginSettings = [];
21+
public function __construct(
22+
protected ConfigurationManagerInterface $configurationManager
23+
) {}
2124

2225
protected function initializeAction(): void
2326
{
@@ -33,9 +36,7 @@ protected function initializeAction(): void
3336
$GLOBALS['BE_USER']->getPagePermsClause(1)
3437
);
3538

36-
$configurationManager = GeneralUtility::makeInstance(
37-
ConfigurationManager::class
38-
);
39+
$configurationManager = $this->configurationManager;
3940

4041
$frameworkConf
4142
= $configurationManager->getConfiguration(

0 commit comments

Comments
 (0)