* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ use PHPUnit\Framework\TestCase; use PrestaShop\Module\AutoUpgrade\UpgradeContainer; class UpgradeContainerTest extends TestCase { public function testSameResultFormAdminSubDir() { $container = new UpgradeContainer(__DIR__, __DIR__ . '/..'); $this->assertNotSame($container->getProperty(UpgradeContainer::PS_ADMIN_SUBDIR), str_replace($container->getProperty(UpgradeContainer::PS_ROOT_PATH), '', $container->getProperty(UpgradeContainer::PS_ADMIN_PATH))); } /** * @dataProvider objectsToInstanciateProvider */ public function testObjectInstanciation($functionName, $expectedClass) { $container = $this->getMockBuilder(UpgradeContainer::class) ->setConstructorArgs([__DIR__, __DIR__ . '/..']) ->setMethods(['getDb']) ->getMock(); $actualClass = get_class(call_user_func([$container, $functionName])); $this->assertSame($actualClass, $expectedClass); } public function objectsToInstanciateProvider() { // | Function to call | Expected class | return [ ['getCacheCleaner', PrestaShop\Module\AutoUpgrade\UpgradeTools\CacheCleaner::class], ['getCookie', PrestaShop\Module\AutoUpgrade\Cookie::class], ['getFileConfigurationStorage', PrestaShop\Module\AutoUpgrade\Parameters\FileConfigurationStorage::class], ['getFileFilter', \PrestaShop\Module\AutoUpgrade\UpgradeTools\FileFilter::class], // array('getUpgrader', \PrestaShop\Module\AutoUpgrade\Upgrader::class), ['getFilesystemAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\FilesystemAdapter::class], ['getLogger', PrestaShop\Module\AutoUpgrade\Log\LegacyLogger::class], ['getModuleAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter::class], ['getState', \PrestaShop\Module\AutoUpgrade\State::class], ['getSymfonyAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\SymfonyAdapter::class], ['getTranslationAdapter', \PrestaShop\Module\AutoUpgrade\UpgradeTools\Translation::class], ['getTranslator', \PrestaShop\Module\AutoUpgrade\UpgradeTools\Translator::class], ['getTwig', \Twig\Environment::class], ['getPrestaShopConfiguration', PrestaShop\Module\AutoUpgrade\PrestashopConfiguration::class], ['getUpgradeConfiguration', PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration::class], ['getWorkspace', PrestaShop\Module\AutoUpgrade\Workspace::class], ['getZipAction', PrestaShop\Module\AutoUpgrade\ZipAction::class], ]; } }