/** * @param bool $isEnable * @param bool $clearStaticContent * @param string $expectedMessage * * @dataProvider executeDataProvider */ public function testExecute($isEnable, $clearStaticContent, $expectedMessage) { $this->status->expects($this->once()) ->method('getModulesToChange') ->with($isEnable, ['Magento_Module1', 'Magento_Module2']) ->will($this->returnValue(['Magento_Module1'])); $this->status->expects($this->any()) ->method('checkConstraints') ->will($this->returnValue([])); $this->status->expects($this->once()) ->method('setIsEnabled') ->with($isEnable, ['Magento_Module1']); $this->cache->expects($this->once()) ->method('clean'); $this->cleanupFiles->expects($this->once()) ->method('clearCodeGeneratedClasses'); $this->cleanupFiles->expects($clearStaticContent ? $this->once() : $this->never()) ->method('clearMaterializedViewFiles'); $commandTester = $isEnable ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider)) : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider)); $input = ['module' => ['Magento_Module1', 'Magento_Module2']]; if ($clearStaticContent) { $input['--clear-static-content'] = true; } $commandTester->execute($input); $this->assertStringMatchesFormat($expectedMessage, $commandTester->getDisplay()); }
private function setUpExecute() { $this->setUpPassValidation(); $this->dependencyChecker->expects($this->once())->method('checkDependenciesWhenDisableModules')->willReturn(['Magento_A' => [], 'Magento_B' => []]); $this->cache->expects($this->once())->method('clean'); $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $languages = $input->getArgument(self::PACKAGE_ARGUMENT); $packagesToRemove = []; $dependencies = $this->dependencyChecker->checkDependencies($languages, true); foreach ($languages as $package) { if (!$this->validate($package)) { $output->writeln("<info>Package {$package} is not a Magento language and will be skipped.</info>"); } else { if (sizeof($dependencies[$package]) > 0) { $output->writeln("<info>Package {$package} has dependencies and will be skipped.</info>"); } else { $packagesToRemove[] = $package; } } } if ($packagesToRemove !== []) { if ($input->getOption(self::BACKUP_CODE_OPTION)) { $backupRestore = $this->backupRollbackFactory->create($output); $backupRestore->codeBackup(time()); } else { $output->writeln('<info>You are removing language package without a code backup.</info>'); } $output->writeln($this->remove->remove($packagesToRemove)); $this->cache->clean(); } else { $output->writeln('<info>Nothing is removed.</info>'); } }
public function testExecute() { $this->objectManager->expects($this->once()) ->method('get') ->with('Magento\Framework\App\Cache') ->willReturn($this->cacheMock); $this->cacheMock->expects($this->once())->method('clean'); $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface'); $writeDirectory->expects($this->atLeastOnce())->method('delete'); $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory); $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true); $progressBar = $this->getMockBuilder( 'Symfony\Component\Console\Helper\ProgressBar' ) ->disableOriginalConstructor() ->getMock(); $this->objectManager->expects($this->once())->method('configure'); $this->objectManager ->expects($this->once()) ->method('create') ->with('Symfony\Component\Console\Helper\ProgressBar') ->willReturn($progressBar); $this->manager->expects($this->exactly(6))->method('addOperation'); $this->manager->expects($this->once())->method('process'); $tester = new CommandTester($this->command); $tester->execute([]); $this->assertContains( 'Generated code and dependency injection configuration successfully.', explode(PHP_EOL, $tester->getDisplay()) ); }
private function setUpExecute($input) { $this->setUpPassValidation(); $this->remove->expects($this->once())->method('remove')->with(['magento/package-a', 'magento/package-b']); $this->dependencyChecker->expects($this->once()) ->method('checkDependenciesWhenDisableModules') ->willReturn(['Magento_A' => [], 'Magento_B' => []]); $this->dataSetup->expects($this->exactly(count($input['module'])))->method('deleteTableRow'); $this->deploymentConfig->expects($this->once()) ->method('getConfigData') ->with(ConfigOptionsListConstants::KEY_MODULES) ->willReturn(['Magento_A' => 1, 'Magento_B' => 1, 'Magento_C' => 0, 'Magento_D' => 1]); $this->loader->expects($this->once()) ->method('load') ->with($input['module']) ->willReturn(['Magento_C' => [], 'Magento_D' => []]); $this->writer->expects($this->once()) ->method('saveConfig') ->with( [ ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['Magento_C' => 0, 'Magento_D' => 1]] ] ); $this->cache->expects($this->once())->method('clean'); $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses'); }
/** * Do the cleanup * * @return void */ protected function performCleanup() { $this->status->add('Cleaning generated files...', \Psr\Log\LogLevel::INFO); $this->cleanupFiles->clearCodeGeneratedFiles(); $this->status->add('Complete!', \Psr\Log\LogLevel::INFO); $this->status->add('Clearing cache...', \Psr\Log\LogLevel::INFO); $this->cache->clean(); $this->status->add('Complete!', \Psr\Log\LogLevel::INFO); }
public function testExecute() { $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn(null); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\App\\Cache')->willReturn($this->cacheMock); $this->cacheMock->expects($this->once())->method('clean'); $writeDirectory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $writeDirectory->expects($this->atLeastOnce())->method('delete'); $this->filesystemMock->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory); $this->deploymentConfigMock->expects($this->once())->method('get')->with(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES)->willReturn(['Magento_Catalog' => 1]); $progressBar = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\ProgressBar')->disableOriginalConstructor()->getMock(); $this->objectManagerMock->expects($this->once())->method('configure'); $this->objectManagerMock->expects($this->once())->method('create')->with('Symfony\\Component\\Console\\Helper\\ProgressBar')->willReturn($progressBar); $this->managerMock->expects($this->exactly(7))->method('addOperation'); $this->managerMock->expects($this->once())->method('process'); $tester = new CommandTester($this->command); $tester->execute([]); $this->assertContains('Generated code and dependency injection configuration successfully.', explode(PHP_EOL, $tester->getDisplay())); $this->assertSame(DiCompileCommand::NAME, $this->command->getName()); }
public function setUpExecute() { $this->setUpPassValidation(); $this->setupPassThemeInUseCheck(); $this->setupPassChildThemeCheck(); $this->setupPassDependencyCheck(); $this->cache->expects($this->once())->method('clean'); $this->themeUninstaller->expects($this->once())->method('uninstallRegistry')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->anything()); $this->themeUninstaller->expects($this->once())->method('uninstallCode')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->anything()); }
public function setUpExecute() { $this->setUpPassValidation(); $this->setupPassChildThemeCheck(); $this->dependencyChecker->expects($this->once())->method('checkDependencies')->willReturn([]); $this->remove->expects($this->once())->method('remove'); $this->cache->expects($this->once())->method('clean'); $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false); $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturn($theme); }
public function testExecutePackageNoLanguage() { $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' => 'library']); $this->remove->expects($this->never())->method('remove'); $this->cache->expects($this->never())->method('clean'); $this->tester->execute(['package' => ['vendor/language-ua_ua']]); $this->assertContains('Package vendor/language-ua_ua is not a Magento language and will be skipped', $this->tester->getDisplay()); $this->assertContains('Nothing is removed.', $this->tester->getDisplay()); }
/** * Cleanup after updated modules status * * @param InputInterface $input * @param OutputInterface $output * @return void */ private function cleanup(InputInterface $input, OutputInterface $output) { $this->cache->clean(); $output->writeln('<info>Cache cleared successfully.</info>'); if ($input->getOption(self::INPUT_KEY_CLEAR_STATIC_CONTENT)) { $this->cleanupFiles->clearMaterializedViewFiles(); $output->writeln('<info>Generated static view files cleared successfully.</info>'); } else { $output->writeln('<error>Alert: Generated static view files were not cleared.' . ' You can clear them using the --' . self::INPUT_KEY_CLEAR_STATIC_CONTENT . ' option.' . ' Failure to clear static view files might cause display issues in the Admin and storefront.</error>'); } }
public function testExecute() { $this->objectManager->expects($this->once()) ->method('get') ->with('Magento\Framework\App\Cache') ->willReturn($this->cacheMock); $this->cacheMock->expects($this->once())->method('clean'); $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface'); $writeDirectory->expects($this->atLeastOnce())->method('delete'); $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory); $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true); $this->objectManager->expects($this->once())->method('configure'); $this->manager->expects($this->exactly(6))->method('addOperation'); $this->manager->expects($this->once())->method('process'); $tester = new CommandTester($this->command); $tester->execute([]); $this->assertEquals( 'Generated code and dependency injection configuration successfully.' . PHP_EOL, $tester->getDisplay() ); }
public function testCleanByEmptyTags() { $this->_cacheFrontendMock->expects($this->once())->method('clean')->with(\Zend_Cache::CLEANING_MODE_ALL)->will($this->returnValue(true)); $this->assertTrue($this->_model->clean()); }
public function removeTagValues($tag) { $tags = array(\Ess\M2ePro\Helper\Data::CUSTOM_IDENTIFIER . '_' . $tag); $this->cache->clean($tags); }