diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index 0bf24206b..a215adc57 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -41,16 +41,6 @@ class Application extends BaseApplication */ public const APP_VERSION = '3.0.0-dev'; - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_1 = 1; - - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_2 = 2; - /** * @var string */ @@ -96,16 +86,6 @@ class Application extends BaseApplication */ protected $_magentoEnterprise = false; - /** - * @var int - */ - protected $_magentoMajorVersion = self::MAGENTO_MAJOR_VERSION_1; - - /** - * @var EntryPoint - */ - protected $_magento2EntryPoint = null; - /** * @var bool */ @@ -265,7 +245,6 @@ public function detectMagento(InputInterface $input = null, OutputInterface $out $this->_magentoDetected = $magentoHelper->detect($folder, $subFolders); $this->_magentoRootFolder = $magentoHelper->getRootFolder(); $this->_magentoEnterprise = $magentoHelper->isEnterpriseEdition(); - $this->_magentoMajorVersion = $magentoHelper->getMajorVersion(); $this->_magerunStopFileFound = $magentoHelper->isMagerunStopFileFound(); $this->_magerunStopFileFolder = $magentoHelper->getMagerunStopFileFolder(); $this->_magerunUseDeveloperMode = ($input->getParameterOption('--developer-mode')); @@ -460,12 +439,7 @@ public function initMagento($soft = false) return false; } - $isMagento2 = $this->_magentoMajorVersion === self::MAGENTO_MAJOR_VERSION_2; - if ($isMagento2) { - $this->_initMagento2(); - } else { - $this->_initMagento1($soft); - } + $this->_initMagento1($soft); return true; } @@ -507,14 +481,6 @@ public function setMagentoRootFolder($magentoRootFolder) $this->_magentoRootFolder = $magentoRootFolder; } - /** - * @return int - */ - public function getMagentoMajorVersion() - { - return $this->_magentoMajorVersion; - } - /** * @return ClassLoader */ @@ -786,50 +752,6 @@ protected function _initMagento1($soft = false) } } - /** - * @return void - */ - protected function _initMagento2() - { - $this->outputMagerunCompatibilityNotice('2'); - } - - /** - * Show a hint that this is Magento incompatible with Magerun and how to obtain the correct Magerun for it - * - * @param string $version of Magento, "1" or "2", that is incompatible - */ - private function outputMagerunCompatibilityNotice($version) - { - $file = $version === '2' ? $version : ''; - $magentoHint = <<Download with curl ------------------- - - curl -O https://files.magerun.net/n98-magerun$file.phar - -Download with wget ------------------- - - wget https://files.magerun.net/n98-magerun$file.phar - -MAGENTOHINT; - - $output = new ConsoleOutput(); - - /** @var FormatterHelper $formatter */ - $formatter = $this->getHelperSet()->get('formatter'); - - $output->writeln(['', $formatter->formatBlock('Compatibility Notice', 'bg=blue;fg=white', true), '', $magentoHint]); - - throw new RuntimeException('This version of n98-magerun is not compatible with Magento ' . $version); - } - /** * @return EventDispatcher */ diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index a022daf40..9a4bfd560 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -32,26 +32,11 @@ */ abstract class AbstractMagentoCommand extends Command { - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_1 = 1; - - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_2 = 2; - /** * @var string */ protected $_magentoRootFolder = null; - /** - * @var int - */ - protected $_magentoMajorVersion = self::MAGENTO_MAJOR_VERSION_1; - /** * @var bool */ @@ -181,7 +166,6 @@ public function detectMagento(OutputInterface $output, $silent = true) $this->_magentoEnterprise = $this->getApplication()->isMagentoEnterprise(); $this->_magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); - $this->_magentoMajorVersion = $this->getApplication()->getMagentoMajorVersion(); if (!$silent) { $editionString = ($this->_magentoEnterprise ? ' (Enterprise Edition) ' : ''); @@ -213,9 +197,6 @@ protected function requireEnterprise(OutputInterface $output) */ protected function getCoreHelper() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::helper('Mage_Core_Helper_Data'); - } return Mage::helper('core'); } @@ -369,83 +350,48 @@ protected function checkDeprecatedAliases(InputInterface $input, OutputInterface } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getModel($mage1code, $mage2class) + protected function _getModel($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getModel($mage2class); - } else { - return Mage::getModel($mage1code); - } + return Mage::getModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Helper_Abstract */ - protected function _getHelper($mage1code, $mage2class) + protected function _getHelper($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::helper($mage2class); - } else { - return Mage::helper($mage1code); - } + return Mage::helper($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getSingleton($mage1code, $mage2class) + protected function _getSingleton($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getModel($mage2class); - } else { - return Mage::getModel($mage1code); - } + return Mage::getModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getResourceModel($mage1code, $mage2class) + protected function _getResourceModel($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getResourceModel($mage2class); - } else { - return Mage::getResourceModel($mage1code); - } + return Mage::getResourceModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getResourceSingleton($mage1code, $mage2class) + protected function _getResourceSingleton($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getResourceSingleton($mage2class); - } else { - return Mage::getResourceSingleton($mage1code); - } + return Mage::getResourceSingleton($class); } /** diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 860fbffe2..a43bf6dbc 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -60,14 +60,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->setRoleType('G') ->save(); - // @todo check cmuench correct class name? - $resourceAll = ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) ? - Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL : 'all'; - // give "all" privileges to role $this->getRulesModel() ->setRoleId($role->getId()) - ->setResources([$resourceAll]) + ->setResources(['all']) ->saveRel(); $output->writeln('The role Development was automatically created.'); @@ -78,14 +74,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->getUserModel() ->setData(['username' => $username, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $password, 'is_active' => 1])->save(); - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $user->setRoleId($role->getId()) - ->save(); - } else { - $user->setRoleIds([$role->getId()]) - ->setRoleUserId($user->getUserId()) - ->saveRelations(); - } + $user->setRoleIds([$role->getId()]) + ->setRoleUserId($user->getUserId()) + ->saveRelations(); $output->writeln('User ' . $username . ' successfully created'); } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index 558160c94..bfb38b42f 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -18,11 +18,7 @@ class AbstractCacheCommand extends AbstractMagentoCommand */ protected function _getCacheModel() { - if ($this->_magentoMajorVersion == AbstractMagentoCommand::MAGENTO_MAJOR_VERSION_2) { - throw new RuntimeException('There global Mage class was removed from Magento 2. What should we do here?'); - } else { - return Mage::app()->getCacheInstance(); - } + return Mage::app()->getCacheInstance(); } /** @@ -93,12 +89,4 @@ protected function _canUseBanCacheFunction() { return method_exists('\Mage_Core_Model_App', 'baseInit'); } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->getMagentoMajorVersion() === Application::MAGENTO_MAJOR_VERSION_1; - } } diff --git a/src/N98/Magento/Command/Config/AbstractConfigCommand.php b/src/N98/Magento/Command/Config/AbstractConfigCommand.php index f644fa62d..ebcfe5114 100644 --- a/src/N98/Magento/Command/Config/AbstractConfigCommand.php +++ b/src/N98/Magento/Command/Config/AbstractConfigCommand.php @@ -16,16 +16,11 @@ abstract class AbstractConfigCommand extends AbstractMagentoCommand protected $_scopes = ['default', 'websites', 'stores']; /** - * @return \Mage_Core_Model_Encryption|null returns null for Magento2 + * @return \Mage_Core_Model_Encryption */ protected function getEncryptionModel() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - // @TODO Magento 2 support - return null; - } else { - return Mage::helper('core')->getEncryptor(); - } + return Mage::helper('core')->getEncryptor(); } /** diff --git a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php index d8a54b43d..d20e4e899 100644 --- a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php +++ b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php @@ -73,30 +73,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_1) { - $classMaps = []; + $classMaps = []; - foreach ($this->groups as $group) { - $classMaps[$group] = $this->getClassMapForGroup($group, $output); + foreach ($this->groups as $group) { + $classMaps[$group] = $this->getClassMapForGroup($group, $output); - if (!$input->getOption('stdout') && count($classMaps[$group]) > 0) { - $output->writeln( - 'Generated definitions for ' . $group . ' group' - ); - } + if (!$input->getOption('stdout') && count($classMaps[$group]) > 0) { + $output->writeln( + 'Generated definitions for ' . $group . ' group' + ); } + } - $version = $input->getOption('meta-version'); - if ($version == self::VERSION_OLD) { - $this->writeToOutputOld($input, $output, $classMaps); - } elseif ($version == self::VERSION_2017) { - $this->writeToOutputV2017($input, $output, $classMaps); - } elseif ($version == self::VERSION_2019) { - $this->writeToOutputV2019($input, $output, $classMaps); - } - } else { - $output->write('Magento 2 is currently not supported'); + $version = $input->getOption('meta-version'); + if ($version == self::VERSION_OLD) { + $this->writeToOutputOld($input, $output, $classMaps); + } elseif ($version == self::VERSION_2017) { + $this->writeToOutputV2017($input, $output, $classMaps); + } elseif ($version == self::VERSION_2019) { + $this->writeToOutputV2019($input, $output, $classMaps); } + return 0; } diff --git a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php index 8809a17f7..ec41260e7 100644 --- a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php @@ -49,35 +49,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $time = microtime(true); $this->detectMagento($output); - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $output->writeln('Magento 2 is currently not supported.'); - } else { - $referenceFiles = $this->getChecksums( - $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('originalTheme') - ); - $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('theme'); - $themeFiles = $this->getChecksums($themeFolder); + $referenceFiles = $this->getChecksums( + $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('originalTheme') + ); + + $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('theme'); + $themeFiles = $this->getChecksums($themeFolder); - $duplicates = []; - foreach ($themeFiles as $themeFilename => $themeFileChecksum) { - if (isset($referenceFiles[$themeFilename]) - && $themeFileChecksum == $referenceFiles[$themeFilename] - ) { - $duplicates[] = $themeFolder . '/' . $themeFilename; - } + $duplicates = []; + foreach ($themeFiles as $themeFilename => $themeFileChecksum) { + if (isset($referenceFiles[$themeFilename]) + && $themeFileChecksum == $referenceFiles[$themeFilename] + ) { + $duplicates[] = $themeFolder . '/' . $themeFilename; } + } - if ($input->getOption('log-junit')) { - $this->logJUnit($input, $duplicates, $input->getOption('log-junit'), microtime($time) - $time); + if ($input->getOption('log-junit')) { + $this->logJUnit($input, $duplicates, $input->getOption('log-junit'), microtime($time) - $time); + } else { + if (count($duplicates) === 0) { + $output->writeln('No duplicates were found'); } else { - if (count($duplicates) === 0) { - $output->writeln('No duplicates were found'); - } else { - $output->writeln($duplicates); - } + $output->writeln($duplicates); } } + return 0; } diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 5f5aaec37..ba4c1d34b 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -59,16 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function getThemes() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $collection = Mage::getModel('Mage_Core_Model_Theme')->getLabelsCollection(); - $themes = []; - foreach ($collection as $theme) { - $themes[] = $theme['label']; - } - - return [$themes]; - } - return Mage::getModel('core/design_package')->getThemeList(); } } diff --git a/src/N98/Util/Console/Helper/MagentoHelper.php b/src/N98/Util/Console/Helper/MagentoHelper.php index 18d2e9300..50f707e47 100644 --- a/src/N98/Util/Console/Helper/MagentoHelper.php +++ b/src/N98/Util/Console/Helper/MagentoHelper.php @@ -23,11 +23,6 @@ class MagentoHelper extends AbstractHelper */ protected $_magentoRootFolder = null; - /** - * @var int - */ - protected $_magentoMajorVersion = Application::MAGENTO_MAJOR_VERSION_1; - /** * @var bool */ @@ -124,11 +119,6 @@ public function getRootFolder() return $this->_magentoRootFolder; } - public function getEdition() - { - return $this->_magentoMajorVersion; - } - /** * @return bool */ @@ -137,14 +127,6 @@ public function isEnterpriseEdition() return $this->_magentoEnterprise; } - /** - * @return int - */ - public function getMajorVersion() - { - return $this->_magentoMajorVersion; - } - /** * @return boolean */ @@ -320,12 +302,6 @@ protected function _search($searchFolder) $this->_magentoRootFolder = $searchFolder; - // Magento 2 does not have a god class and thus if this file is not there it is version 2 - if ($hasMageFile === false) { - $this->_magentoMajorVersion = Application::MAGENTO_MAJOR_VERSION_2; - return true; // the rest of this does not matter since we are simply exiting with a notice - } - if (is_callable(['\Mage', 'getEdition'])) { $this->_magentoEnterprise = (Mage::getEdition() == 'Enterprise'); } else { diff --git a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php b/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php index b0a0d337a..635fd4fe2 100644 --- a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php +++ b/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php @@ -16,9 +16,7 @@ private function getCommand() { $command = new UnlockCommand(); $command->setApplication($this->getApplication()); - if (!$command->isEnabled()) { - self::markTestSkipped('UnlockCommand is not enabled.'); - } + return $command; } diff --git a/tests/N98/Magento/Command/Cache/CleanCommandTest.php b/tests/N98/Magento/Command/Cache/CleanCommandTest.php index de1c4b3b3..92c1945c0 100644 --- a/tests/N98/Magento/Command/Cache/CleanCommandTest.php +++ b/tests/N98/Magento/Command/Cache/CleanCommandTest.php @@ -19,10 +19,6 @@ public function getApplication() { $application = parent::getApplication(); - if ($application::MAGENTO_MAJOR_VERSION_1 !== $application->getMagentoMajorVersion()) { - return $application; - } - // FIXME #613 make install command work with 1.9+ and cache initialization $version = Mage::getVersion(); $against = '1.9.0.0'; diff --git a/tests/N98/Magento/Command/Cache/DisableCommandTest.php b/tests/N98/Magento/Command/Cache/DisableCommandTest.php index 5e1200aed..e5cdca618 100644 --- a/tests/N98/Magento/Command/Cache/DisableCommandTest.php +++ b/tests/N98/Magento/Command/Cache/DisableCommandTest.php @@ -11,31 +11,27 @@ class DisableCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); + $application->add(new DisableCommand()); - $command = $this->getApplication()->find('cache:disable'); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:disable'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay()); } public function testExecuteMultipleCaches() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); - - $command = $this->getApplication()->find('cache:disable'); - $commandTester = new CommandTester($command); - $commandTester->execute( - ['command' => $command->getName(), 'code' => 'eav,config'] - ); - - self::assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay()); - self::assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay()); - } + $application->add(new DisableCommand()); + + $command = $this->getApplication()->find('cache:disable'); + $commandTester = new CommandTester($command); + $commandTester->execute( + ['command' => $command->getName(), 'code' => 'eav,config'] + ); + + self::assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay()); + self::assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Cache/EnableCommandTest.php b/tests/N98/Magento/Command/Cache/EnableCommandTest.php index b50ef1656..63ba10e0c 100644 --- a/tests/N98/Magento/Command/Cache/EnableCommandTest.php +++ b/tests/N98/Magento/Command/Cache/EnableCommandTest.php @@ -11,31 +11,27 @@ class EnableCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new EnableCommand()); - $command = $this->getApplication()->find('cache:enable'); + $application->add(new EnableCommand()); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:enable'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay()); } public function testExecuteMultipleCaches() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); - - $command = $this->getApplication()->find('cache:enable'); - $commandTester = new CommandTester($command); - $commandTester->execute( - ['command' => $command->getName(), 'code' => 'eav,config'] - ); - - self::assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay()); - self::assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay()); - } + $application->add(new DisableCommand()); + + $command = $this->getApplication()->find('cache:enable'); + $commandTester = new CommandTester($command); + $commandTester->execute( + ['command' => $command->getName(), 'code' => 'eav,config'] + ); + + self::assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay()); + self::assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Cache/FlushCommandTest.php b/tests/N98/Magento/Command/Cache/FlushCommandTest.php index 51b00e001..bbba8dd7f 100644 --- a/tests/N98/Magento/Command/Cache/FlushCommandTest.php +++ b/tests/N98/Magento/Command/Cache/FlushCommandTest.php @@ -11,15 +11,12 @@ class FlushCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application = $this->getApplication(); - $application->add(new FlushCommand()); - $command = $this->getApplication()->find('cache:flush'); + $application->add(new FlushCommand()); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:flush'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php index 87b27c5ea..baed68423 100644 --- a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php +++ b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php @@ -22,29 +22,19 @@ class DeleteCommandTest extends TestCase protected $website; protected $application; - protected function getResourceClassName($mage1Code, $mage2Code) + protected function getResourceClassName($class) { - // Get correct model classes to mock - if ($this->application->getMagentoMajorVersion() == 2) { - return get_class(Mage::getResourceModel($mage2Code)); - } else { - return get_class(Mage::getResourceModel($mage1Code)); - } + return get_class(Mage::getResourceModel($class)); } - protected function getModelClassName($mage1Code, $mage2Code) + protected function getModelClassName($class) { - // Get correct model classes to mock - if ($this->application->getMagentoMajorVersion() == 2) { - return get_class(Mage::getModel($mage2Code)); - } else { - return get_class(Mage::getModel($mage1Code)); - } + return get_class(Mage::getModel($class)); } protected function getCustomerModel(array $methods) { - $className = $this->getModelClassName('customer/customer', 'Mage_Customer_Model_Customer'); + $className = $this->getModelClassName('customer/customer'); return $this->getMockBuilder($className) ->setMethods($methods) ->disableOriginalConstructor() @@ -54,8 +44,7 @@ protected function getCustomerModel(array $methods) protected function getCustomerCollection(array $methods) { $className = $this->getResourceClassName( - 'customer/customer_collection', - 'Mage_Customer_Model_Resource_Customer_Collection' + 'customer/customer_collection' ); return $this->getMockBuilder($className) diff --git a/tests/N98/Magento/Command/Database/DumpCommandTest.php b/tests/N98/Magento/Command/Database/DumpCommandTest.php index 338f37e0c..fd0ec4a04 100644 --- a/tests/N98/Magento/Command/Database/DumpCommandTest.php +++ b/tests/N98/Magento/Command/Database/DumpCommandTest.php @@ -19,9 +19,6 @@ class DumpCommandTest extends TestCase protected function getCommand() { $dumpCommand = new DumpCommand(); - if (!$dumpCommand->isEnabled()) { - self::markTestSkipped('DumpCommand is not enabled.'); - } $application = $this->getApplication(); $application->add($dumpCommand); diff --git a/tests/N98/Magento/TestApplication.php b/tests/N98/Magento/TestApplication.php index 150ef2698..4387b86ad 100644 --- a/tests/N98/Magento/TestApplication.php +++ b/tests/N98/Magento/TestApplication.php @@ -171,9 +171,7 @@ public function getApplication() $application->init(); $application->initMagento(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']); - } + spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']); $this->application = $application; } diff --git a/tests/N98/Util/Console/Helper/MagentoHelper.php b/tests/N98/Util/Console/Helper/MagentoHelper.php index 19f1b4398..b90bcef44 100644 --- a/tests/N98/Util/Console/Helper/MagentoHelper.php +++ b/tests/N98/Util/Console/Helper/MagentoHelper.php @@ -40,7 +40,6 @@ public function detectMagentoInStandardFolder() $helper->detect(vfsStream::url('root'), []); self::assertEquals(vfsStream::url('root'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); } /** @@ -62,7 +61,6 @@ public function detectMagentoInHtdocsSubfolder() ); self::assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); } /** @@ -104,29 +102,5 @@ public function detectMagentoInModmanInfrastructure() // Verify if this could be checked with more elegance self::assertEquals(vfsStream::url('root/../root/htdocs/magento_root'), $helper->getRootFolder()); - - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); - } - - /** - * @test - */ - public function detectMagento2InHtdocsSubfolder() - { - vfsStream::setup('root'); - vfsStream::create( - ['htdocs' => ['app' => ['autoload.php' => '', 'bootstrap.php' => '']]] - ); - - $helper = $this->getHelper(); - - // vfs cannot resolve relative path so we do 'root/htdocs' etc. - $helper->detect( - vfsStream::url('root'), - [vfsStream::url('root/www'), vfsStream::url('root/public'), vfsStream::url('root/htdocs')] - ); - - self::assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_2, $helper->getMajorVersion()); } }