Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions Build/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?php

use TYPO3\CMS\Core\Cache\Backend\NullBackend;
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Package\Cache\PackageCacheInterface;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Package\UnitTestPackageManager;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Testbase;

/*
* This file is part of the TYPO3 CMS project.
*
Expand All @@ -12,7 +25,6 @@
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Boilerplate for a unit test phpunit boostrap file.
*
Expand All @@ -28,7 +40,7 @@
* adapt to extensions needs.
*/
(static function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
$testbase = new Testbase();

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

$testbase->defineSitePath();

$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
$requestType = SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI;
\TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, $requestType);

$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3conf/ext');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/assets');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/tests');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/transient');

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

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

$cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend(
$cache = new PhpFrontend(
'core',
new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
new NullBackend('production', [])
);

// Set all packages to active
if (interface_exists(\TYPO3\CMS\Core\Package\Cache\PackageCacheInterface::class)) {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, \TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache));
if (interface_exists(PackageCacheInterface::class)) {
$packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, Bootstrap::createPackageCache($cache));
} else {
// v10 compatibility layer
// @deprecated Will be removed when v10 compat is dropped from testing-framework
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, $cache);
$packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, $cache);
}

\TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
ExtensionManagementUtility::setPackageManager($packageManager);

$testbase->dumpClassLoadingInformation();

\TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
GeneralUtility::purgeInstances();
})();
192 changes: 188 additions & 4 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,21 +1,205 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#"
message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Classes/Controller/Cart/OrderController.php

-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:getTaxClass\\(\\)\\.$#"
message: '#^Instanceof between Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface and Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 1
path: ../Classes/Domain/Model/Cart/BeVariant.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:getTaxClass\(\)\.$#'
identifier: method.notFound
count: 2
path: ../Classes/Domain/Model/Cart/Cart.php

-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:setCart\\(\\)\\.$#"
message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:setCart\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Classes/Domain/Model/Cart/Cart.php

-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#"
message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Classes/EventListener/Order/Finish/ClearCart.php

-
message: '#^Method TYPO3\\CMS\\Form\\Mvc\\Persistence\\FormPersistenceManagerInterface\:\:listForms\(\) invoked with 1 parameter, 2 required\.$#'
identifier: arguments.count
count: 1
path: ../Classes/Hooks/FormDefinitions.php

-
message: '#^Parameter \$cacheManager of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\CacheManager\.$#'
identifier: class.notFound
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
message: '#^Parameter \$resourceFactory of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\ResourceFactory\.$#'
identifier: class.notFound
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager has unknown class Extcode\\Cart\\Hooks\\CacheManager as its type\.$#'
identifier: class.notFound
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory has unknown class Extcode\\Cart\\Hooks\\ResourceFactory as its type\.$#'
identifier: class.notFound
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: ../Classes/Hooks/ItemsProcFunc.php

-
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\.$#'
identifier: attribute.deprecated
count: 1
path: ../Classes/Updates/ExtcodeCartCTypeMigration.php

-
message: '''
#^Class Extcode\\Cart\\Updates\\ExtcodeCartCTypeMigration extends deprecated class TYPO3\\CMS\\Install\\Updates\\AbstractListTypeToCTypeUpdate\:
since v14\.0, will be removed in TYPO34 v15\.0\. Use \\TYPO3\\CMS\\Core\\Upgrades\\AbstractListTypeToCTypeUpdate instead\.$#
'''
identifier: class.extendsDeprecatedClass
count: 1
path: ../Classes/Updates/ExtcodeCartCTypeMigration.php

-
message: '#^Loose comparison using \!\= between non\-empty\-string and '''' will always evaluate to true\.$#'
identifier: notEqual.alwaysTrue
count: 1
path: ../Classes/Validation/Validator/EmptyValidator.php

-
message: '#^Access to constant on deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#'
identifier: classConstant.deprecatedClass
count: 1
path: ../Classes/ViewHelpers/IncludeFileViewHelper.php

-
message: '#^Call to method sanitize\(\) of deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#'
identifier: method.deprecatedClass
count: 1
path: ../Classes/ViewHelpers/IncludeFileViewHelper.php

-
message: '#^Strict comparison using \!\=\= between '''' and '''' will always evaluate to false\.$#'
identifier: notIdentical.alwaysFalse
count: 1
path: ../Classes/ViewHelpers/TitleTagViewHelper.php

-
message: '#^Variable \$arguments on left side of \?\? is never defined\.$#'
identifier: nullCoalesce.variable
count: 1
path: ../Classes/ViewHelpers/TitleTagViewHelper.php

-
message: '''
#^Call to deprecated method addPiFlexFormValue\(\) of class TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility\:
Will be removed in TYPO3 v15$#
'''
identifier: staticMethod.deprecated
count: 1
path: ../Configuration/TCA/Overrides/tt_content.php

-
message: '#^Call to an undefined method PHPUnit\\Framework\\MockObject\\MockBuilder\<T of object&TYPO3\\TestingFramework\\Core\\AccessibleObjectInterface\>\:\:disableAutoload\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Cart/BeVariantTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Order\\AbstractAddressTest\:\:getMockForAbstractClass\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php

-
message: '#^Call to an undefined method PHPUnit\\Framework\\MockObject\\MockBuilder\<T of object&TYPO3\\TestingFramework\\Core\\AccessibleObjectInterface\>\:\:addMethods\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 1
path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Order\\AbstractServiceTest\:\:getMockForAbstractClass\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Order/AbstractServiceTest.php

-
message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Discount\(\) on a separate line has no effect\.$#'
identifier: new.resultUnused
count: 6
path: ../Tests/Unit/Domain/Model/Order/DiscountTest.php

-
message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Tax\(\) on a separate line has no effect\.$#'
identifier: new.resultUnused
count: 2
path: ../Tests/Unit/Domain/Model/Order/TaxTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\AbstractProductTest\:\:getMockForAbstractClass\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/AbstractProductTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\CategoryTraitTest\:\:getObjectForTrait\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/CategoryTraitTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\MeasureTraitTest\:\:getObjectForTrait\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/MeasureTraitTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\ServiceAttributeTraitTest\:\:getObjectForTrait\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/ServiceAttributeTraitTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\StockTraitTest\:\:getObjectForTrait\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/StockTraitTest.php

-
message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\TagTraitTest\:\:getObjectForTrait\(\)\.$#'
identifier: method.notFound
count: 1
path: ../Tests/Unit/Domain/Model/Product/TagTraitTest.php
28 changes: 27 additions & 1 deletion Build/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
includes:
- phpstan-baseline.neon
- 'phpstan-baseline.neon'

parameters:
level: 4

paths:
- ../Classes
- ../Configuration
- ../Tests
- ../ext_emconf.php
- ../ext_localconf.php

disallowedFunctionCalls:
-
function:
- 'var_dump()'
- 'xdebug_break()'
message: 'Do not add debugging'
-
function: 'header()'
message: 'Use API instead'

disallowedStaticCalls:
-
method: 'TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()'
message: 'Do not add debugging'

disallowedSuperglobals:
-
superglobal:
- '$_GET'
- '$_POST'
- '$_FILES'
- '$_SERVER'
message: 'Use API instead'
9 changes: 5 additions & 4 deletions Classes/Controller/Backend/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
*/

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
protected array $pluginSettings = [];
public function __construct(
protected ConfigurationManagerInterface $configurationManager
) {}

protected function initializeAction(): void
{
Expand All @@ -33,9 +36,7 @@ protected function initializeAction(): void
$GLOBALS['BE_USER']->getPagePermsClause(1)
);

$configurationManager = GeneralUtility::makeInstance(
ConfigurationManager::class
);
$configurationManager = $this->configurationManager;

$frameworkConf
= $configurationManager->getConfiguration(
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/Backend/Order/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Extcode\Cart\Event\Order\NumberGeneratorEvent;
use Extcode\CartPdf\Service\PdfService;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
Expand Down
Loading
Loading