diff --git a/tests/ContainerTrait.php b/tests/ContainerTrait.php index 0b220a7c90..192eabe0f2 100644 --- a/tests/ContainerTrait.php +++ b/tests/ContainerTrait.php @@ -65,7 +65,6 @@ private function createContainer(): void private function compileContainer(): void { $this->container->compile(true); - $this->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator')->generate(); } private function loadYamlFixture(string $fixtureDir): void diff --git a/tests/Integration/Application/Component/BasketComponentSessionTest.php b/tests/Integration/Application/Component/BasketComponentSessionTest.php index fdbc40a8d1..528b8c2b05 100644 --- a/tests/Integration/Application/Component/BasketComponentSessionTest.php +++ b/tests/Integration/Application/Component/BasketComponentSessionTest.php @@ -20,23 +20,14 @@ final class BasketComponentSessionTest extends IntegrationTestCase { private string $articleId = '1000'; - private bool $configBlUseStock; - public function setUp(): void { parent::setUp(); - $this->configBlUseStock = Registry::getConfig()->getConfigParam('blUseStock'); Registry::getConfig()->setConfigParam('blUseStock', false); Registry::getSession()->setVariable('aLastcall', []); $this->createTestProduct(); } - public function tearDown(): void - { - Registry::getConfig()->setConfigParam('blUseStock', $this->configBlUseStock); - parent::tearDown(); - } - public function testChangingBasketWhenSessionChallengeValidationNotPassed(): void { $this->actAsSearchEngine(false); diff --git a/tests/Integration/Application/Controller/Admin/ModuleConfigurationTest.php b/tests/Integration/Application/Controller/Admin/ModuleConfigurationTest.php index 50906a1850..847c86c38d 100644 --- a/tests/Integration/Application/Controller/Admin/ModuleConfigurationTest.php +++ b/tests/Integration/Application/Controller/Admin/ModuleConfigurationTest.php @@ -28,8 +28,8 @@ final class ModuleConfigurationTest extends IntegrationTestCase public function setUp(): void { - $this->installTestModule(); parent::setUp(); + $this->installTestModule(); } public function tearDown(): void diff --git a/tests/Integration/Application/Controller/Admin/ShopConfigurationTest.php b/tests/Integration/Application/Controller/Admin/ShopConfigurationTest.php index ce25503a01..491219cdba 100644 --- a/tests/Integration/Application/Controller/Admin/ShopConfigurationTest.php +++ b/tests/Integration/Application/Controller/Admin/ShopConfigurationTest.php @@ -17,30 +17,14 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; final class ShopConfigurationTest extends IntegrationTestCase { use ContainerTrait; - use FilesystemTrait; private string $testModuleId = 'testShopModuleId'; - public function setUp(): void - { - parent::setUp(); - - $this->backupVarDirectory(); - } - - public function tearDown(): void - { - $this->restoreVarDirectory(); - - parent::tearDown(); - } - public function testSaveConfVars(): void { $this->prepareTestModuleConfiguration(); diff --git a/tests/Integration/Core/GenericImport/ImportObject/ImportObjectTest.php b/tests/Integration/Core/GenericImport/ImportObject/ImportObjectTest.php index 5d6e9934d5..1714205cf8 100644 --- a/tests/Integration/Core/GenericImport/ImportObject/ImportObjectTest.php +++ b/tests/Integration/Core/GenericImport/ImportObject/ImportObjectTest.php @@ -32,9 +32,9 @@ public function setUp(): void public function tearDown(): void { - parent::setUp(); - Registry::getConfig()->setAdminMode(false); + + parent::tearDown(); } public function testGetFields(): void diff --git a/tests/Integration/Core/LanguageTest.php b/tests/Integration/Core/LanguageTest.php index 29ff585399..1cdadd21cd 100644 --- a/tests/Integration/Core/LanguageTest.php +++ b/tests/Integration/Core/LanguageTest.php @@ -17,46 +17,60 @@ use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; -class LanguageTest extends IntegrationTestCase +use function sprintf; + +final class LanguageTest extends IntegrationTestCase { - public function testTranslateCachedString(): void + public function setUp(): void + { + parent::setUp(); + + ContainerFacade::get(TagAwareCacheInterface::class)->invalidateTags(['oxid_esales.cache.language']); + } + + public function tearDown(): void { - $stringToTranslate = uniqid(); - $cache = ContainerFacade::get(TagAwareCacheInterface::class); + ContainerFacade::get(TagAwareCacheInterface::class)->invalidateTags(['oxid_esales.cache.language']); + + parent::tearDown(); + } + + public function testTranslateStringWithMissingTranslation(): void + { + $translationKey = uniqid('some-key-', true); + $language = new Language(); $logger = $this->createMock(LoggerInterface::class); Registry::set('logger', $logger); - $config = Registry::getConfig(); - $logger->expects($this->once()) ->method('warning') - ->with(sprintf('translation for %s not found', $stringToTranslate), $this->anything()); - - $language = new Language(); - $translatedString = $language->translateString($stringToTranslate, $language->getBaseLanguage()); + ->with(sprintf('translation for %s not found', $translationKey), $this->anything()); - $this->assertEquals($stringToTranslate, $translatedString); + $translation = $language->translateString($translationKey, $language->getBaseLanguage()); - $cache->invalidateTags(['oxid_esales.cache.language']); + $this->assertEquals($translationKey, $translation); + } - $langCacheName = sprintf( + public function testTranslateStringWithTranslationInCache(): void + { + $translationKey = uniqid('some-key-', true); + $cachedTranslation = 'some-translation'; + $language = new Language(); + $cacheKey = sprintf( 'langcache_%d_%s_%d_%s_default', - $config->isAdmin(), + Registry::getConfig()->isAdmin(), $language->getBaseLanguage(), - $config->getShopId(), - $config->getConfigParam('sTheme') + Registry::getConfig()->getShopId(), + Registry::getConfig()->getConfigParam('sTheme') ); + ContainerFacade::get(TagAwareCacheInterface::class) + ->get($cacheKey, function (ItemInterface $item) use ($translationKey, $cachedTranslation) { + $item->tag('oxid_esales.cache.language'); + return [$translationKey => $cachedTranslation]; + }); - $cache->get($langCacheName, function (ItemInterface $item) use ($stringToTranslate) { - $item->tag('oxid_esales.cache.language'); - return [$stringToTranslate => 'translated value']; - }); - - $language = new Language(); - $translatedString = $language->translateString($stringToTranslate, $language->getBaseLanguage()); - - $this->assertEquals('translated value', $translatedString); + $translation = $language->translateString($translationKey, $language->getBaseLanguage()); - $cache->invalidateTags(['oxid_esales.cache.language']); + $this->assertEquals($cachedTranslation, $translation); } } diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index dd2ec05345..b1b67c42d3 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -11,23 +11,27 @@ use OxidEsales\EshopCommunity\Tests\ContainerTrait; use OxidEsales\EshopCommunity\Tests\DatabaseTrait; +use OxidEsales\EshopCommunity\Tests\FilesystemTrait; use PHPUnit\Framework\TestCase; class IntegrationTestCase extends TestCase { use ContainerTrait; use DatabaseTrait; + use FilesystemTrait; public function setUp(): void { parent::setUp(); + $this->backupVarDirectory(); $this->beginTransaction(); } public function tearDown(): void { $this->rollBackTransaction(); + $this->restoreVarDirectory(); parent::tearDown(); } diff --git a/tests/Integration/Internal/ComposerPlugin/ComponentInstallerTest.php b/tests/Integration/Internal/ComposerPlugin/ComponentInstallerTest.php index 5007dfa93d..5e30b04a05 100644 --- a/tests/Integration/Internal/ComposerPlugin/ComponentInstallerTest.php +++ b/tests/Integration/Internal/ComposerPlugin/ComponentInstallerTest.php @@ -13,34 +13,17 @@ use Composer\Package\Package; use OxidEsales\ComposerPlugin\Installer\Package\ComponentInstaller; use OxidEsales\EshopCommunity\Internal\Container\BootstrapContainerFactory; -use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ProjectYamlImportServiceInterface; use OxidEsales\EshopCommunity\Internal\Framework\FileSystem\ProjectRootLocator; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ComponentInstallerTest extends TestCase +final class ComponentInstallerTest extends IntegrationTestCase { use ContainerTrait; - use FilesystemTrait; private string $servicesFilePath = 'Fixtures/services.yaml'; - public function setUp(): void - { - parent::setUp(); - - $this->backupVarDirectory(); - } - - public function tearDown(): void - { - parent::tearDown(); - - $this->restoreVarDirectory(); - } - public function testInstall(): void { $installer = $this->createInstaller(); diff --git a/tests/Integration/Internal/ComposerPlugin/ModulePackageInstallerTest.php b/tests/Integration/Internal/ComposerPlugin/ModulePackageInstallerTest.php index 1af7f37ef1..ec0bca7471 100644 --- a/tests/Integration/Internal/ComposerPlugin/ModulePackageInstallerTest.php +++ b/tests/Integration/Internal/ComposerPlugin/ModulePackageInstallerTest.php @@ -19,32 +19,16 @@ use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ModulePackageInstallerTest extends TestCase +final class ModulePackageInstallerTest extends IntegrationTestCase { use ContainerTrait; - use FilesystemTrait; - private $modulePackagePath = __DIR__ . '/Fixtures/test-module-package-installation'; + private string $modulePackagePath = __DIR__ . '/Fixtures/test-module-package-installation'; private string $packageName = 'test-module-package-installation'; private string $moduleId = 'testModule'; - public function setUp(): void - { - parent::setUp(); - - $this->backupVarDirectory(); - } - - public function tearDown(): void - { - $this->restoreVarDirectory(); - - parent::tearDown(); - } - public function testModuleNotInstalledByDefault(): void { $installer = $this->getPackageInstaller($this->packageName); diff --git a/tests/Integration/Internal/Framework/DIContainer/Dao/ParameterDaoTest.php b/tests/Integration/Internal/Framework/DIContainer/Dao/ParameterDaoTest.php index 4046cf1c2c..e2cff63ff9 100644 --- a/tests/Integration/Internal/Framework/DIContainer/Dao/ParameterDaoTest.php +++ b/tests/Integration/Internal/Framework/DIContainer/Dao/ParameterDaoTest.php @@ -12,28 +12,12 @@ use OxidEsales\EshopCommunity\Core\Di\ContainerFacade; use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Dao\ParameterDaoInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; -final class ParameterDaoTest extends TestCase +final class ParameterDaoTest extends IntegrationTestCase { use ContainerTrait; - use FilesystemTrait; - - public function setUp(): void - { - parent::setUp(); - - $this->backupVarDirectory(); - } - - public function tearDown(): void - { - parent::tearDown(); - - $this->restoreVarDirectory(); - } public function testAddWithMultipleParameters(): void { diff --git a/tests/Integration/Internal/Framework/DIContainer/Dao/ProjectYamlDaoTest.php b/tests/Integration/Internal/Framework/DIContainer/Dao/ProjectYamlDaoTest.php index 8bcfdbc532..d5ff0f34ca 100644 --- a/tests/Integration/Internal/Framework/DIContainer/Dao/ProjectYamlDaoTest.php +++ b/tests/Integration/Internal/Framework/DIContainer/Dao/ProjectYamlDaoTest.php @@ -43,9 +43,9 @@ public function setup(): void public function tearDown(): void { - parent::tearDown(); - (new Filesystem())->remove($this->tmpFixture); + + parent::tearDown(); } public function testLadProjectConfigFileWillWorkWithEmptyFile(): void diff --git a/tests/Integration/Internal/Framework/DIContainer/Service/FilesystemContainerCacheTest.php b/tests/Integration/Internal/Framework/DIContainer/Service/FilesystemContainerCacheTest.php index 8456dcb905..b191c0c74f 100644 --- a/tests/Integration/Internal/Framework/DIContainer/Service/FilesystemContainerCacheTest.php +++ b/tests/Integration/Internal/Framework/DIContainer/Service/FilesystemContainerCacheTest.php @@ -20,6 +20,8 @@ final class FilesystemContainerCacheTest extends TestCase public function tearDown(): void { $this->get(ContainerCacheInterface::class)->invalidate(2); + + parent::tearDown(); } public function testContainerCacheInvalidation(): void diff --git a/tests/Integration/Internal/Framework/Database/ConnectionFactoryTest.php b/tests/Integration/Internal/Framework/Database/ConnectionFactoryTest.php index 5a62111ed8..bc08f13152 100644 --- a/tests/Integration/Internal/Framework/Database/ConnectionFactoryTest.php +++ b/tests/Integration/Internal/Framework/Database/ConnectionFactoryTest.php @@ -23,8 +23,8 @@ final class ConnectionFactoryTest extends TestCase public function tearDown(): void { - parent::tearDown(); unlink($this->logFile); + parent::tearDown(); } public function testSqlLoggerWritesExpectedValueToTheLog(): void diff --git a/tests/Integration/Internal/Framework/FileSystem/FileGenerator/CsvFileGeneratorTest.php b/tests/Integration/Internal/Framework/FileSystem/FileGenerator/CsvFileGeneratorTest.php index f19f7fdda5..b1393bf9f8 100644 --- a/tests/Integration/Internal/Framework/FileSystem/FileGenerator/CsvFileGeneratorTest.php +++ b/tests/Integration/Internal/Framework/FileSystem/FileGenerator/CsvFileGeneratorTest.php @@ -36,9 +36,9 @@ protected function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->filesystem->remove($this->filename); + + parent::tearDown(); } public function testGenerateIfDataExists(): void diff --git a/tests/Integration/Internal/Framework/Module/Command/ModuleCommandsTestCase.php b/tests/Integration/Internal/Framework/Module/Command/ModuleCommandsTestCase.php index 17614c6c57..f92903124e 100644 --- a/tests/Integration/Internal/Framework/Module/Command/ModuleCommandsTestCase.php +++ b/tests/Integration/Internal/Framework/Module/Command/ModuleCommandsTestCase.php @@ -12,12 +12,12 @@ use OxidEsales\EshopCommunity\Core\Di\ContainerFacade; use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\DataObject\OxidEshopPackage; use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleInstallerInterface; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Filesystem\Path; -class ModuleCommandsTestCase extends TestCase +class ModuleCommandsTestCase extends IntegrationTestCase { protected string $modulesPath = __DIR__ . '/Fixtures/modules/'; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ModuleSettingBridgeTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ModuleSettingBridgeTest.php index db526eaf4a..3bc8d9b929 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ModuleSettingBridgeTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ModuleSettingBridgeTest.php @@ -13,9 +13,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleConfigurationInstallerInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ModuleSettingBridgeTest extends TestCase +final class ModuleSettingBridgeTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ShopConfigurationDaoBridgeTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ShopConfigurationDaoBridgeTest.php index d77ac349f4..1cf7bdf8a1 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ShopConfigurationDaoBridgeTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Bridge/ShopConfigurationDaoBridgeTest.php @@ -13,9 +13,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ShopConfiguration; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ShopConfigurationDaoBridgeTest extends TestCase +final class ShopConfigurationDaoBridgeTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/Chain/ClassExtensionsChainDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/Chain/ClassExtensionsChainDaoTest.php index ed953f24c7..243a2f45f2 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/Chain/ClassExtensionsChainDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/Chain/ClassExtensionsChainDaoTest.php @@ -12,9 +12,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\Chain\ClassExtensionsChainDaoInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ClassExtensionsChain; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ClassExtensionsChainDaoTest extends TestCase +final class ClassExtensionsChainDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleConfigurationDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleConfigurationDaoTest.php index 7c538ad963..b3f58c0c1d 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleConfigurationDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleConfigurationDaoTest.php @@ -16,11 +16,11 @@ use OxidEsales\EshopCommunity\Internal\Framework\Storage\FileStorageFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Filesystem\Path; -final class ModuleConfigurationDaoTest extends TestCase +final class ModuleConfigurationDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleDependencyDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleDependencyDaoTest.php index 7d0d1db9be..3f048c2a9e 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleDependencyDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleDependencyDaoTest.php @@ -14,11 +14,11 @@ use OxidEsales\EshopCommunity\Internal\Framework\Storage\FileStorageFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\TestCase; #[Group('module-dependency')] -final class ModuleDependencyDaoTest extends TestCase +final class ModuleDependencyDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleEnvironmentConfigurationDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleEnvironmentConfigurationDaoTest.php index 7a6105e41b..260b3220ca 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleEnvironmentConfigurationDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleEnvironmentConfigurationDaoTest.php @@ -14,10 +14,10 @@ use OxidEsales\EshopCommunity\Internal\Framework\Storage\FileStorageFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\TestCase; -final class ModuleEnvironmentConfigurationDaoTest extends TestCase +final class ModuleEnvironmentConfigurationDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleTemplateExtensionChainTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleTemplateExtensionChainTest.php index 494f47273a..3c82795395 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleTemplateExtensionChainTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ModuleTemplateExtensionChainTest.php @@ -11,12 +11,12 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopConfigurationDaoInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\TestContainerFactory; use OxidEsales\EshopCommunity\Tests\Unit\Internal\BasicContextStub; -use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -final class ModuleTemplateExtensionChainTest extends TestCase +final class ModuleTemplateExtensionChainTest extends IntegrationTestCase { private ShopConfigurationDaoInterface $shopConfigurationDao; private int $shopId = 1; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ProjectConfigurationDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ProjectConfigurationDaoTest.php index ffd5501e53..68373a9253 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ProjectConfigurationDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ProjectConfigurationDaoTest.php @@ -22,11 +22,11 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ProjectConfigurationIsEmptyException; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\TestContainerFactory; -use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -final class ProjectConfigurationDaoTest extends TestCase +final class ProjectConfigurationDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopConfigurationDaoTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopConfigurationDaoTest.php index b4cfab4b11..68fc487b88 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopConfigurationDaoTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopConfigurationDaoTest.php @@ -19,9 +19,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Storage\FileStorageFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ShopConfigurationDaoTest extends TestCase +final class ShopConfigurationDaoTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopEnvironmentMisconfigurationEventSubscriberTest.php b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopEnvironmentMisconfigurationEventSubscriberTest.php index f1286fdf56..c1afa1a91d 100644 --- a/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopEnvironmentMisconfigurationEventSubscriberTest.php +++ b/tests/Integration/Internal/Framework/Module/Configuration/Dao/ShopEnvironmentMisconfigurationEventSubscriberTest.php @@ -12,13 +12,13 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopEnvironmentWithOrphanSettingEvent; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\Unit\Internal\ContextStub; -use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Filesystem\Path; -final class ShopEnvironmentMisconfigurationEventSubscriberTest extends TestCase +final class ShopEnvironmentMisconfigurationEventSubscriberTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php b/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php index dc148c359b..65fd20ba9e 100644 --- a/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php +++ b/tests/Integration/Internal/Framework/Module/Facade/ActiveModulesDataProviderTest.php @@ -24,11 +24,11 @@ use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContext; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\TestCase; use Symfony\Component\Filesystem\Path; -final class ActiveModulesDataProviderTest extends TestCase +final class ActiveModulesDataProviderTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php b/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php index 1ed7181357..5d6ca370b4 100644 --- a/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php +++ b/tests/Integration/Internal/Framework/Module/Facade/ModuleSettingServiceTest.php @@ -15,11 +15,11 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use function Symfony\Component\String\u; -final class ModuleSettingServiceTest extends TestCase +final class ModuleSettingServiceTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Facade/ModulesDataProviderTest.php b/tests/Integration/Internal/Framework/Module/Facade/ModulesDataProviderTest.php index b1ece8f370..faa8606558 100644 --- a/tests/Integration/Internal/Framework/Module/Facade/ModulesDataProviderTest.php +++ b/tests/Integration/Internal/Framework/Module/Facade/ModulesDataProviderTest.php @@ -15,10 +15,10 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Service\ModuleActivationServiceInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContext; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use Symfony\Component\Filesystem\Path; -final class ModulesDataProviderTest extends TestCase +final class ModulesDataProviderTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Install/Service/BootstrapModuleInstallerTest.php b/tests/Integration/Internal/Framework/Module/Install/Service/BootstrapModuleInstallerTest.php index e428310e5b..6e57ff06bd 100644 --- a/tests/Integration/Internal/Framework/Module/Install/Service/BootstrapModuleInstallerTest.php +++ b/tests/Integration/Internal/Framework/Module/Install/Service/BootstrapModuleInstallerTest.php @@ -14,9 +14,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleInstallerInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class BootstrapModuleInstallerTest extends TestCase +final class BootstrapModuleInstallerTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleConfigurationInstallerTest.php b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleConfigurationInstallerTest.php index 92f7698ffa..f47e32ee01 100644 --- a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleConfigurationInstallerTest.php +++ b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleConfigurationInstallerTest.php @@ -21,10 +21,10 @@ use OxidEsales\EshopCommunity\Internal\Framework\Storage\FileStorageFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\TestCase; -final class ModuleConfigurationInstallerTest extends TestCase +final class ModuleConfigurationInstallerTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleFilesInstallerTest.php b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleFilesInstallerTest.php index 4d2c965f49..f13178094d 100644 --- a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleFilesInstallerTest.php +++ b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleFilesInstallerTest.php @@ -13,10 +13,10 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleFilesInstallerInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use Symfony\Component\Filesystem\Path; -final class ModuleFilesInstallerTest extends TestCase +final class ModuleFilesInstallerTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleInstallerTest.php b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleInstallerTest.php index f511a3fd01..a668ea2c5a 100644 --- a/tests/Integration/Internal/Framework/Module/Install/Service/ModuleInstallerTest.php +++ b/tests/Integration/Internal/Framework/Module/Install/Service/ModuleInstallerTest.php @@ -14,9 +14,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleInstallerInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ModuleInstallerTest extends TestCase +final class ModuleInstallerTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Module/Setup/Service/ModuleDependencyActivationTest.php b/tests/Integration/Internal/Framework/Module/Setup/Service/ModuleDependencyActivationTest.php index 78508e4806..a3e1fd3293 100644 --- a/tests/Integration/Internal/Framework/Module/Setup/Service/ModuleDependencyActivationTest.php +++ b/tests/Integration/Internal/Framework/Module/Setup/Service/ModuleDependencyActivationTest.php @@ -29,11 +29,11 @@ final class ModuleDependencyActivationTest extends IntegrationTestCase public function setup(): void { + parent::setUp(); + $moduleInstaller = $this->get(ModuleInstallerInterface::class); $moduleInstaller->install(new OxidEshopPackage($this->testDependentModulePath)); $moduleInstaller->install(new OxidEshopPackage($this->testModuleWithDependencyPath)); - - parent::setUp(); } public function tearDown(): void diff --git a/tests/Integration/Internal/Framework/Module/Setup/Validator/ServicesYamlValidatorTest.php b/tests/Integration/Internal/Framework/Module/Setup/Validator/ServicesYamlValidatorTest.php index feded6c5dd..961a87d06a 100644 --- a/tests/Integration/Internal/Framework/Module/Setup/Validator/ServicesYamlValidatorTest.php +++ b/tests/Integration/Internal/Framework/Module/Setup/Validator/ServicesYamlValidatorTest.php @@ -15,14 +15,14 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Exception\InvalidModuleServicesException; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Validator\ModuleConfigurationValidatorInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Validator\ServicesYamlValidator; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\Unit\Internal\ContextStub; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Path; -final class ServicesYamlValidatorTest extends TestCase +final class ServicesYamlValidatorTest extends IntegrationTestCase { private ModuleConfigurationValidatorInterface $validator; private ModuleConfiguration $moduleConfiguration; diff --git a/tests/Integration/Internal/Framework/Module/State/ModuleStateServiceTest.php b/tests/Integration/Internal/Framework/Module/State/ModuleStateServiceTest.php index ce78fb21be..04607bcd9c 100644 --- a/tests/Integration/Internal/Framework/Module/State/ModuleStateServiceTest.php +++ b/tests/Integration/Internal/Framework/Module/State/ModuleStateServiceTest.php @@ -13,9 +13,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration; use OxidEsales\EshopCommunity\Internal\Framework\Module\State\ModuleStateServiceInterface; use OxidEsales\EshopCommunity\Tests\ContainerTrait; -use PHPUnit\Framework\TestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; -final class ModuleStateServiceTest extends TestCase +final class ModuleStateServiceTest extends IntegrationTestCase { use ContainerTrait; diff --git a/tests/Integration/Internal/Framework/Theme/Command/ThemeActivateCommandTest.php b/tests/Integration/Internal/Framework/Theme/Command/ThemeActivateCommandTest.php index 7d63241e6f..a4f2f5f7ab 100644 --- a/tests/Integration/Internal/Framework/Theme/Command/ThemeActivateCommandTest.php +++ b/tests/Integration/Internal/Framework/Theme/Command/ThemeActivateCommandTest.php @@ -21,44 +21,36 @@ final class ThemeActivateCommandTest extends IntegrationTestCase private string $fixtureDirectory = __DIR__ . '/Fixtures'; - private string $themeId = 'testTheme'; + private string $initialThemeId = 'some-theme-id'; + private string $newThemeId = 'testTheme'; private array $originalConfig; public function setUp(): void { parent::setUp(); - $this->saveOriginalConfig(); $this->setShopFixtures(); } - public function tearDown(): void - { - $this->restoreOriginalConfig(); - parent::tearDown(); - } - public function testThemeActivationOnSuccess(): void { - $arguments = ['theme-id' => $this->themeId]; - - $themeActivateCommand = $this->getCommandObject(); - $commandTester = new CommandTester($themeActivateCommand); + $this->createCommandTester() + ->execute( + ['theme-id' => $this->newThemeId] + ); - $commandTester->execute($arguments); - $this->assertSame($this->themeId, $this->getActiveTheme()); + $this->assertSame($this->newThemeId, $this->getActiveTheme()); } public function testThemeAlreadyActivated(): void { - $arguments = ['theme-id' => $this->themeId]; + $arguments = ['theme-id' => $this->newThemeId]; + $commandTester = $this->createCommandTester(); - $themeActivateCommand = $this->getCommandObject(); - $commandTester = new CommandTester($themeActivateCommand); $commandTester->execute($arguments); - $commandTester->execute($arguments); //running twice is important + $commandTester->execute($arguments); $this->assertStringContainsString( - sprintf('Theme - "%s" is already active.', $this->themeId), + \sprintf('Theme - "%s" is already active.', $this->newThemeId), $commandTester->getDisplay() ); } @@ -66,23 +58,15 @@ public function testThemeAlreadyActivated(): void public function testNonExistingThemeActivation(): void { $nonExistingThemeId = 'some-theme-id'; - $arguments = ['theme-id' => $nonExistingThemeId]; + $commandTester = $this->createCommandTester(); - $themeActivateCommand = $this->getCommandObject(); - $commandTester = new CommandTester($themeActivateCommand); - $commandTester->execute($arguments); + $commandTester->execute(['theme-id' => $nonExistingThemeId]); $this->assertStringContainsString( sprintf('Theme - "%s" not found.', $nonExistingThemeId), $commandTester->getDisplay() ); - - $this->assertSame('absolute-dummy-value', $this->getActiveTheme()); - } - - private function getCommandObject(): ThemeActivateCommand - { - return $this->get(ThemeActivateCommand::class); + $this->assertSame($this->initialThemeId, $this->getActiveTheme()); } private function getActiveTheme(): string @@ -93,7 +77,7 @@ private function getActiveTheme(): string private function setShopFixtures(): void { Registry::getConfig()->reinitialize(); - Registry::getConfig()->setConfigParam('sTheme', 'absolute-dummy-value'); + Registry::getConfig()->setConfigParam('sTheme', $this->initialThemeId); $this->createContainer(); $this->container->setParameter('oxid_esales.shop_source_directory', "$this->fixtureDirectory/shop/source/"); @@ -101,16 +85,8 @@ private function setShopFixtures(): void $this->attachContainerToContainerFactory(); } - private function saveOriginalConfig(): void + private function createCommandTester(): CommandTester { - $this->originalConfig = [ - 'sTheme' => Registry::getConfig()->getConfigParam('sTheme') - ]; - } - - private function restoreOriginalConfig(): void - { - Registry::getConfig()->reinitialize(); - Registry::getConfig()->setConfigParam('sTheme', $this->originalConfig['sTheme']); + return new CommandTester($this->get(ThemeActivateCommand::class)); } } diff --git a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatCurrencyLogicTest.php b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatCurrencyLogicTest.php index 5da924798a..e864c9e4cc 100644 --- a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatCurrencyLogicTest.php +++ b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatCurrencyLogicTest.php @@ -19,8 +19,8 @@ final class FormatCurrencyLogicTest extends IntegrationTestCase public function setUp(): void { - $this->numberFormatLogic = new FormatCurrencyLogic(); parent::setUp(); + $this->numberFormatLogic = new FormatCurrencyLogic(); } #[DataProvider('numberFormatProvider')] diff --git a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatDateLogicTest.php b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatDateLogicTest.php index fc30cb8b30..91add68b0a 100644 --- a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatDateLogicTest.php +++ b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/FormatDateLogicTest.php @@ -19,8 +19,8 @@ final class FormatDateLogicTest extends TestCase public function setUp(): void { - $this->formDateLogic = new FormatDateLogic(); parent::setUp(); + $this->formDateLogic = new FormatDateLogic(); } public function testFormdateWithEmptyValue(): void diff --git a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/TruncateLogicTest.php b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/TruncateLogicTest.php index 7bf99a2a14..edace3b703 100644 --- a/tests/Integration/Internal/Transition/Adapter/TemplateLogic/TruncateLogicTest.php +++ b/tests/Integration/Internal/Transition/Adapter/TemplateLogic/TruncateLogicTest.php @@ -19,6 +19,8 @@ final class TruncateLogicTest extends TestCase public function setup(): void { + parent::setUp(); + $this->truncateLogic = new TruncateLogic(); } diff --git a/tests/Integration/Legacy/Application/Controller/Admin/PaymentRDFaTest.php b/tests/Integration/Legacy/Application/Controller/Admin/PaymentRDFaTest.php index 4eebfecb3a..67e297c8e7 100644 --- a/tests/Integration/Legacy/Application/Controller/Admin/PaymentRDFaTest.php +++ b/tests/Integration/Legacy/Application/Controller/Admin/PaymentRDFaTest.php @@ -20,11 +20,8 @@ final class PaymentRDFaTest extends IntegrationTestCase use ContainerTrait; private string $paymentId; - private string $descriptionInDefaultLanguage = 'description-in-default-language'; - private string $descriptionInLanguage1 = 'description-in-lang-1'; - public function setUp(): void { $this->replaceContainerInstance(); diff --git a/tests/Integration/Legacy/Application/Model/SeoEncoderCategoryTest.php b/tests/Integration/Legacy/Application/Model/SeoEncoderCategoryTest.php index 4b259ade6c..ab0d801a99 100644 --- a/tests/Integration/Legacy/Application/Model/SeoEncoderCategoryTest.php +++ b/tests/Integration/Legacy/Application/Model/SeoEncoderCategoryTest.php @@ -34,10 +34,10 @@ final class SeoEncoderCategoryTest extends IntegrationTestCase public function setUp(): void { + parent::setUp(); + $this->replaceContainerInstance(); $this->resetDatabaseProvider(); - - parent::setUp(); } public function testOnDeleteCategoryWillSetDependantRecordsToExpired(): void diff --git a/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementation.php b/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementation.php index 40d6a0fb39..de26b8cb14 100644 --- a/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementation.php +++ b/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementation.php @@ -15,7 +15,6 @@ use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface; use OxidEsales\EshopCommunity\Core\DatabaseProvider; -use OxidEsales\EshopCommunity\Tests\ContainerTrait; use PHPUnit\Framework\Attributes\DataProvider; use ReflectionClass; @@ -28,8 +27,6 @@ */ abstract class DatabaseInterfaceImplementation extends DatabaseInterfaceImplementationBase { - use ContainerTrait; - /** * The data provider for the method testGetAllForAllFetchModes. * diff --git a/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementationBase.php b/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementationBase.php index 8386a0453f..fbbe8cc9e8 100644 --- a/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementationBase.php +++ b/tests/Integration/Legacy/Core/Database/Adapter/DatabaseInterfaceImplementationBase.php @@ -82,19 +82,19 @@ public static function setUpBeforeClass(): void public static function tearDownAfterClass(): void { - self::getDatabaseHandler()->exec('DROP TABLE ' . self::TABLE_NAME . ';'); + self::getDatabaseHandler()->exec('DROP TABLE IF EXISTS ' . self::TABLE_NAME . ';'); parent::tearDownAfterClass(); } public function setUp(): void { + parent::setUp(); + /** Set a user-defined error handler in order to handle errors triggered with trigger_error */ $this->errors = []; set_error_handler($this->errorHandler(...)); - parent::setUp(); - $this->initializeDatabase(); $this->truncateTestTable(); $this->assureTestTableIsEmpty(); diff --git a/tests/Integration/Legacy/Core/Database/Adapter/Doctrine/DatabaseTest.php b/tests/Integration/Legacy/Core/Database/Adapter/Doctrine/DatabaseTest.php index 5c6480ae8d..861b4e975b 100644 --- a/tests/Integration/Legacy/Core/Database/Adapter/Doctrine/DatabaseTest.php +++ b/tests/Integration/Legacy/Core/Database/Adapter/Doctrine/DatabaseTest.php @@ -11,7 +11,6 @@ use Exception; use InvalidArgumentException; -use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface; use OxidEsales\EshopCommunity\Core\Database\Adapter\Doctrine\ResultSet; use OxidEsales\EshopCommunity\Core\Exception\DatabaseErrorException; diff --git a/tests/Integration/Legacy/Core/Module/ModuleListTest.php b/tests/Integration/Legacy/Core/Module/ModuleListTest.php index a84c285b5a..88085b353f 100644 --- a/tests/Integration/Legacy/Core/Module/ModuleListTest.php +++ b/tests/Integration/Legacy/Core/Module/ModuleListTest.php @@ -24,16 +24,7 @@ final class ModuleListTest extends IntegrationTestCase { public function setUp(): void { - $this->getContainer() - ->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator') - ->generate(); - parent::setUp(); - } - - public function tearDown(): void - { - parent::tearDown(); $this->getContainer() ->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator') diff --git a/tests/Integration/Legacy/Core/UtilsFileLocalImagesHandlingTest.php b/tests/Integration/Legacy/Core/UtilsFileLocalImagesHandlingTest.php index 8ee642a558..c072b27d7c 100644 --- a/tests/Integration/Legacy/Core/UtilsFileLocalImagesHandlingTest.php +++ b/tests/Integration/Legacy/Core/UtilsFileLocalImagesHandlingTest.php @@ -42,8 +42,8 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); $this->clearTestDirectories(); + parent::tearDown(); } public function testProcessFilesWillCopyFile(): void diff --git a/tests/Integration/Legacy/Modules/ModuleInheritanceTest.php b/tests/Integration/Legacy/Modules/ModuleInheritanceTest.php index 905634ecba..6a33d871cf 100644 --- a/tests/Integration/Legacy/Modules/ModuleInheritanceTest.php +++ b/tests/Integration/Legacy/Modules/ModuleInheritanceTest.php @@ -19,7 +19,6 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Exception\InvalidClassExtensionNamespaceException; use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapter; use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidEsales\EshopCommunity\Tests\Integration\Legacy\Modules\TestDataInheritance\modules\module_chain_extension_3_1\vendor_1_module_3_1_myclass; use OxidEsales\EshopCommunity\Tests\Integration\Legacy\Modules\TestDataInheritance\modules\module_native_extension\ContentController as ModuleContentController; @@ -35,7 +34,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; - use function Symfony\Component\String\u; /** @@ -99,21 +97,17 @@ */ final class ModuleInheritanceTest extends IntegrationTestCase { - use FilesystemTrait; - private ContainerInterface $container; public function setUp(): void { parent::setUp(); - $this->backupVarDirectory(); $this->container = ContainerFactory::getInstance()->getContainer(); } public function tearDown(): void { - $this->restoreVarDirectory(); $this->container->get(ShopCacheCleanerInterface::class)->clear(1); parent::tearDown(); diff --git a/tests/Integration/Legacy/Modules/ModuleTranslationsTest.php b/tests/Integration/Legacy/Modules/ModuleTranslationsTest.php index e8b7b694f5..bb5528e18c 100644 --- a/tests/Integration/Legacy/Modules/ModuleTranslationsTest.php +++ b/tests/Integration/Legacy/Modules/ModuleTranslationsTest.php @@ -15,27 +15,10 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\DataObject\OxidEshopPackage; use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleInstallerInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; -use OxidEsales\EshopCommunity\Tests\FilesystemTrait; use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; final class ModuleTranslationsTest extends IntegrationTestCase { - use FilesystemTrait; - - public function setUp(): void - { - parent::setUp(); - - $this->backupVarDirectory(); - } - - public function tearDown(): void - { - $this->restoreVarDirectory(); - - parent::tearDown(); - } - public function testTranslation(): void { $this->get(ModuleInstallerInterface::class) diff --git a/tests/Integration/Legacy/Modules/OnlineModuleNotifierTest.php b/tests/Integration/Legacy/Modules/OnlineModuleNotifierTest.php index 366933e916..4ef56b90e4 100644 --- a/tests/Integration/Legacy/Modules/OnlineModuleNotifierTest.php +++ b/tests/Integration/Legacy/Modules/OnlineModuleNotifierTest.php @@ -30,18 +30,9 @@ final class OnlineModuleNotifierTest extends IntegrationTestCase private array $installedModules = []; - public function setUp(): void - { - parent::setUp(); - - $this->installedModules = []; - $this->backupVarDirectory(); - } - public function tearDown(): void { $this->uninstallTestedModules(); - $this->restoreVarDirectory(); $this->get(ShopCacheCleanerInterface::class)->clear(1); parent::tearDown(); diff --git a/tests/Integration/Legacy/Multilanguage/AdditionalTablesTest.php b/tests/Integration/Legacy/Multilanguage/AdditionalTablesTest.php index 4f10e802d2..60ec3cf832 100644 --- a/tests/Integration/Legacy/Multilanguage/AdditionalTablesTest.php +++ b/tests/Integration/Legacy/Multilanguage/AdditionalTablesTest.php @@ -26,9 +26,9 @@ final class AdditionalTablesTest extends TestCase public function tearDown(): void { - parent::tearDown(); - $this->setupShopDatabase(); + + parent::tearDown(); } public function testCreateLanguagesAfterAdditionalTable(): void diff --git a/tests/Integration/Legacy/Multilanguage/ViewTest.php b/tests/Integration/Legacy/Multilanguage/ViewTest.php index cfecb98e0e..752b8e243c 100644 --- a/tests/Integration/Legacy/Multilanguage/ViewTest.php +++ b/tests/Integration/Legacy/Multilanguage/ViewTest.php @@ -34,9 +34,9 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->setupShopDatabase(); + + parent::tearDown(); } public function testMultilanguageViewsAddLanguagesAfterAddingProduct(): void diff --git a/tests/TestContainerFactory.php b/tests/TestContainerFactory.php index 74db90b844..efbae69710 100644 --- a/tests/TestContainerFactory.php +++ b/tests/TestContainerFactory.php @@ -9,8 +9,6 @@ namespace OxidEsales\EshopCommunity\Tests; -use org\bovigo\vfs\vfsStream; -use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\ContainerBuilder; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; @@ -18,75 +16,23 @@ use OxidEsales\EshopCommunity\Tests\Unit\Internal\ContextStub; use Symfony\Component\DependencyInjection\ContainerBuilder as SymfonyContainerBuilder; -/** - * @internal - */ class TestContainerFactory { - /** - * @var BasicContextStub - */ - private ContextStub $context; - - public function __construct() - { - $this->prepareVFS(); - $this->context = $this->getContextStub(); - } - public function create(): SymfonyContainerBuilder { - $containerBuilder = new ContainerBuilder($this->context); - - $container = $containerBuilder->getContainer(); - $container = $this->setAllServicesAsPublic($container); - $container = $this->setBasicContextStub($container); - $container = $this->setContextStub($container); + $contextStub = new ContextStub(); + $container = (new ContainerBuilder($contextStub)) + ->getContainer(); - return $container; - } + $container->set(ContextInterface::class, $contextStub); + $container->set(BasicContextInterface::class, $contextStub); + $container->autowire(BasicContextInterface::class, BasicContextStub::class); + $container->autowire(ContextInterface::class, ContextStub::class); - private function setAllServicesAsPublic(SymfonyContainerBuilder $container): SymfonyContainerBuilder - { foreach ($container->getDefinitions() as $definition) { $definition->setPublic(true); } return $container; } - - private function setBasicContextStub(SymfonyContainerBuilder $container): SymfonyContainerBuilder - { - $container->set(BasicContextInterface::class, $this->context); - $container->autowire(BasicContextInterface::class, BasicContextStub::class); - - return $container; - } - - private function setContextStub(SymfonyContainerBuilder $container): SymfonyContainerBuilder - { - $container->set(ContextInterface::class, $this->context); - $container->autowire(ContextInterface::class, ContextStub::class); - - return $container; - } - - private function getContextStub(): ContextStub - { - $context = new ContextStub(); - $context->setProjectConfigurationDirectory($this->getTestProjectConfigurationDirectory()); - - return $context; - } - - private function prepareVFS(): void - { - $vfsStreamDirectory = vfsStream::setup('configuration'); - vfsStream::create([], $vfsStreamDirectory); - } - - private function getTestProjectConfigurationDirectory(): string - { - return vfsStream::url('configuration/'); - } }