/** * @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'); }
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'); }
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()); }
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() ); }