public function setUp() { $maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( 'Magento\Framework\ObjectManagerInterface', [], '', false ); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); $this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); $this->backupRollbackFactory = $this->getMock( 'Magento\Framework\Setup\BackupRollbackFactory', [], [], '', false ); $this->backupRollbackFactory->expects($this->any()) ->method('create') ->willReturn($this->backupRollback); $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValue($this->backupRollbackFactory)); $command = new BackupCommand( $objectManagerProvider, $maintenanceMode, $this->deploymentConfig ); $this->tester = new CommandTester($command); }
public function testExecuteNoBackupOption() { $dependencies['vendor/language-ua_ua'] = []; $this->dependencyChecker->expects($this->once())->method('checkDependencies')->with(['vendor/language-ua_ua'])->willReturn($dependencies); $this->composerInfo->expects($this->once())->method('getRootRequiredPackagesAndTypes')->willReturn(['vendor/language-ua_ua' => 'magento2-language']); $this->backupRollbackFactory->expects($this->never())->method('create'); $this->remove->expects($this->once())->method('remove'); $this->cache->expects($this->once())->method('clean'); $this->tester->execute(['package' => ['vendor/language-ua_ua']]); $this->assertContains('You are removing language package without a code backup.', $this->tester->getDisplay()); }
/** * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function setUp() { $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false); $this->fullModuleList = $this->getMock('Magento\\Framework\\Module\\FullModuleList', [], [], '', false); $this->maintenanceMode = $this->getMock('Magento\\Framework\\App\\MaintenanceMode', [], [], '', false); $objectManagerProvider = $this->getMock('Magento\\Setup\\Model\\ObjectManagerProvider', [], [], '', false); $objectManager = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface', [], '', false); $this->uninstallCollector = $this->getMock('Magento\\Setup\\Model\\UninstallCollector', [], [], '', false); $this->packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false); $packageInfoFactory = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false); $packageInfoFactory->expects($this->once())->method('create')->willReturn($this->packageInfo); $this->dependencyChecker = $this->getMock('Magento\\Framework\\Module\\DependencyChecker', [], [], '', false); $this->backupRollback = $this->getMock('Magento\\Framework\\Setup\\BackupRollback', [], [], '', false); $this->backupRollbackFactory = $this->getMock('Magento\\Framework\\Setup\\BackupRollbackFactory', [], [], '', false); $this->backupRollbackFactory->expects($this->any())->method('create')->willReturn($this->backupRollback); $this->cache = $this->getMock('Magento\\Framework\\App\\Cache', [], [], '', false); $this->cleanupFiles = $this->getMock('Magento\\Framework\\App\\State\\CleanupFiles', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($objectManager); $configLoader = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface', [], '', false); $configLoader->expects($this->any())->method('load')->willReturn([]); $objectManager->expects($this->any())->method('get')->will($this->returnValueMap([['Magento\\Framework\\Module\\PackageInfoFactory', $packageInfoFactory], ['Magento\\Framework\\Module\\DependencyChecker', $this->dependencyChecker], ['Magento\\Framework\\App\\Cache', $this->cache], ['Magento\\Framework\\App\\State\\CleanupFiles', $this->cleanupFiles], ['Magento\\Framework\\App\\State', $this->getMock('Magento\\Framework\\App\\State', [], [], '', false)], ['Magento\\Framework\\Setup\\BackupRollbackFactory', $this->backupRollbackFactory], ['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface', $configLoader]])); $composer = $this->getMock('Magento\\Framework\\Composer\\ComposerInformation', [], [], '', false); $composer->expects($this->any())->method('getRootRequiredPackages')->willReturn(['magento/package-a', 'magento/package-b']); $this->moduleUninstaller = $this->getMock('Magento\\Setup\\Model\\ModuleUninstaller', [], [], '', false); $this->moduleRegistryUninstaller = $this->getMock('Magento\\Setup\\Model\\ModuleRegistryUninstaller', [], [], '', false); $this->command = new ModuleUninstallCommand($composer, $this->deploymentConfig, $this->fullModuleList, $this->maintenanceMode, $objectManagerProvider, $this->uninstallCollector, $this->moduleUninstaller, $this->moduleRegistryUninstaller); $this->question = $this->getMock('Symfony\\Component\\Console\\Helper\\QuestionHelper', [], [], '', false); $this->question->expects($this->any())->method('ask')->will($this->returnValue(true)); $this->helperSet = $this->getMock('Symfony\\Component\\Console\\Helper\\HelperSet', [], [], '', false); $this->helperSet->expects($this->any())->method('get')->with('question')->will($this->returnValue($this->question)); $this->command->setHelperSet($this->helperSet); $this->tester = new CommandTester($this->command); }
public function setUp() { $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( 'Magento\Framework\ObjectManagerInterface', [], '', false ); $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); $this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); $this->backupRollbackFactory = $this->getMock( 'Magento\Framework\Setup\BackupRollbackFactory', [], [], '', false ); $this->backupRollbackFactory->expects($this->any()) ->method('create') ->willReturn($this->backupRollback); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], ])); $this->helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); $this->question = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper', [], [], '', false); $this->question ->expects($this->any()) ->method('ask') ->will($this->returnValue(true)); $this->helperSet ->expects($this->any()) ->method('get') ->with('question') ->will($this->returnValue($this->question)); $this->command = new RollbackCommand( $objectManagerProvider, $maintenanceMode, $this->deploymentConfig ); $this->command->setHelperSet($this->helperSet); $this->tester = new CommandTester($this->command); }
public function testExecuteWithBackupCode() { $this->setUpExecute(); $backupRollback = $this->getMock('Magento\\Framework\\Setup\\BackupRollback', [], [], '', false); $this->backupRollbackFactory->expects($this->once())->method('create')->willReturn($backupRollback); $this->tester->execute(['theme' => ['test'], '--backup-code' => true]); $this->tester->getDisplay(); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Could not complete */ public function testExceptionOnExecute() { $this->backupRollbackFactory->expects($this->once())->method('create')->willThrowException(new \Exception()); $this->jobDbRollback->execute(); }