public function testItDisplaysAConfirmationMessageIfThereWasNoException() { $expectedMessage = 'Status of product "test": ' . ProductStatusAdapterInterface::DISABLED; $this->mockOutput->expects($this->once())->method('writeln')->with($this->stringStartsWith('<info>' . $expectedMessage)); $this->mockInput->method('getArgument')->willReturn('test'); $this->command->run($this->mockInput, $this->mockOutput); }
public function testItDisplaysAMessageIfThereAreNoMatches() { $this->mockInput->method('getArgument')->with('sku')->willReturn('TEST'); $this->mockProductStatusAdapter->method('getProductStatusMatchingSku')->willReturn([]); $this->mockOutput->expects($this->once())->method('writeln')->with('<comment>No matches found for "TEST"</comment>'); $this->command->run($this->mockInput, $this->mockOutput); }
public function testItDisplaysAConfirmationMessage() { $expectedMessage = 'Status of product "test": enabled'; $this->mockOutput->expects($this->once())->method('writeln')->with('<info>' . $expectedMessage . '</info>'); $this->mockInput->method('getArgument')->willReturn('test'); $this->command->run($this->mockInput, $this->mockOutput); }
public function testRunWithDefaultValues() { $this->output->expects(self::atLeastOnce())->method('writeln'); $input = new ArgvInput(array()); $actual = $this->sut->run($input, $this->output); self::assertEmpty($actual); }
/** * @dataProvider withTagsProvider * @param int $level * @param string $message * @param string $expected */ public function testLogWithTags($level, $message, $expected) { $this->output->expects($this->once())->method('getVerbosity')->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)); $this->output->expects($this->exactly(1))->method('writeln')->with($expected); $logger = new OutputLogger($this->output, true, null, null, true); $logger->log($level, $message); }
public function testRemoveModulesFromDeploymentConfig() { $this->output->expects($this->atLeastOnce())->method('writeln'); $this->deploymentConfig->expects($this->once())->method('getConfigData')->willReturn(['moduleA' => 1, 'moduleB' => 1, 'moduleC' => 1, 'moduleD' => 1]); $this->loader->expects($this->once())->method('load')->willReturn(['moduleC' => [], 'moduleD' => []]); $this->writer->expects($this->once())->method('saveConfig')->with([ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['moduleC' => 1, 'moduleD' => 1]]]); $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($this->output, ['moduleA', 'moduleB']); }
public function testUninstallCode() { $this->output->expects($this->atLeastOnce())->method('writeln'); $this->themePackageInfo->expects($this->at(0))->method('getPackageName')->willReturn('packageA'); $this->themePackageInfo->expects($this->at(1))->method('getPackageName')->willReturn('packageB'); $this->themePackageInfo->expects($this->at(2))->method('getPackageName')->willReturn('packageC'); $this->remove->expects($this->once())->method('remove')->with(['packageA', 'packageB', 'packageC'])->willReturn(''); $this->themeProvider->expects($this->never())->method($this->anything()); $this->themeUninstaller->uninstallCode($this->output, ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']); }
public function testUninstallRemoveCode() { $this->moduleRegistryUninstaller->expects($this->never())->method($this->anything()); $this->output->expects($this->once())->method('writeln'); $packageInfoFactory = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false); $packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false); $packageInfo->expects($this->atLeastOnce())->method('getPackageName'); $packageInfoFactory->expects($this->once())->method('create')->willReturn($packageInfo); $this->objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Module\\PackageInfoFactory')->willReturn($packageInfoFactory); $this->remove->expects($this->once())->method('remove'); $this->uninstaller->uninstallCode($this->output, ['moduleA', 'moduleB']); }
/** * @dataProvider getMessages * * @param string $method * @param bool $append * @param string|array $messages1 * @param string|array $messages2 * @param bool $newline * @param int $type */ public function testWrite($method, $append, $messages1, $messages2, $newline, $type) { $export = new Export($this->output, $this->file, $append); if ($method == 'write') { $this->output->expects($this->at(0))->method($method)->with($messages1, $newline, $type); $this->output->expects($this->at(1))->method($method)->with($messages2, $newline, $type); call_user_func([$export, $method], $messages1, $newline, $type); call_user_func([$export, $method], $messages2, $newline, $type); } else { $newline = true; $this->output->expects($this->at(0))->method($method)->with($messages1, $type); $this->output->expects($this->at(1))->method($method)->with($messages2, $type); call_user_func([$export, $method], $messages1, $type); call_user_func([$export, $method], $messages2, $type); } $expected = ''; if ($append) { foreach ((array) $messages1 as $message) { $expected .= strip_tags($message) . ($newline ? PHP_EOL : ''); } } foreach ((array) $messages2 as $message) { $expected .= strip_tags($message) . ($newline ? PHP_EOL : ''); } $export->unlock(); $this->assertEquals($expected, file_get_contents($this->file)); }
/** * @dataProvider getMessagesTypes * * @param string|array $messages * @param int $type */ public function testWriteLnLazy($messages, $type) { $_m = (array) $messages; foreach ($_m as $index => $message) { $this->output->expects($this->at($index))->method('writeln')->with($message, $type); } $this->lazy_write->writeln($messages, $type); $this->lazy_write->writeAll(); }
/** * Test quietness * * @dataProvider dataQuietness */ public function testQuietness($quiet, $noInteraction, $confirmation, $countWriteln, $countDescriber, $countClient, $countExecute) { $this->input->expects($this->any())->method('getOption')->will($this->returnValueMap(array(array('quiet', $quiet), array('no-interaction', $noInteraction)))); $this->questionHelper->expects($this->any())->method('ask')->will($this->returnValue($confirmation)); $this->output->expects($countWriteln)->method('writeln'); $this->gearmanDescriber->expects($countDescriber)->method('describeJob')->will($this->returnValue('olakase')); $this->gearmanClient->expects($countClient)->method('getJob')->will($this->returnValue(array())); $this->gearmanExecute->expects($countExecute)->method('executeJob'); $this->command->setGearmanClient($this->gearmanClient)->setGearmanDescriber($this->gearmanDescriber)->setGearmanExecute($this->gearmanExecute)->setKernel($this->kernel)->run($this->input, $this->output); }
public function testRegenerateStatic() { $storeLocales = ['fr_FR', 'de_DE', 'nl_NL']; $adminUserInterfaceLocales = ['de_DE', 'en_US']; $this->storeViewMock->expects($this->once())->method('retrieveLocales')->willReturn($storeLocales); $userMock = $this->getMock(\Magento\User\Model\User::class, [], [], '', false); $userMock->expects($this->once())->method('getInterfaceLocale')->willReturn('en_US'); $this->userCollectionMock->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([$userMock])); $usedLocales = array_unique(array_merge($storeLocales, $adminUserInterfaceLocales)); $staticContentDeployCmd = $this->cmdPrefix . 'setup:static-content:deploy ' . implode(' ', $usedLocales); $setupDiCompileCmd = $this->cmdPrefix . 'setup:di:compile'; $this->shellMock->expects($this->at(0))->method('execute')->with($staticContentDeployCmd); $this->shellMock->expects($this->at(1))->method('execute')->with($setupDiCompileCmd); $this->outputMock->expects($this->at(0))->method('writeln')->with('Starting deployment of static content'); $this->outputMock->expects($this->at(2))->method('writeln')->with('Deployment of static content complete'); $this->outputMock->expects($this->at(3))->method('writeln')->with('Starting compilation'); $this->outputMock->expects($this->at(5))->method('writeln')->with('Compilation complete'); $this->filesystem->regenerateStatic($this->outputMock); }
/** * Ctagger should not be run when $devMode is false */ public function testCtagDevModeFalse() { $this->assertFileNotExists($this->testTempDir . '/tags'); $this->composerMock->expects($this->exactly(0))->method('getConfig'); $this->outputMock->expects($this->once())->method('write')->with('PhpCtagger: Composer is not in dev mode. Will not create/modify ctags file.'); $class = $this->ctagCommandMock; $class::staticExpects($this->exactly(0))->method('getCommand'); $event = new \Composer\Script\Event('dummy-event-name', $this->composerMock, $this->consoleIO, $devMode = false); Ctagger::setCtagCommand($this->ctagCommandMock); Ctagger::setTagsDir($this->testTempDir); Ctagger::ctag($event); $this->assertFileNotExists($this->testTempDir . '/tags'); }
/** * testItLogsToOutputIfAnExceptionIsThrownDuringIndexing */ public function testItLogsToOutputIfAnExceptionIsThrownDuringIndexing() { $this->container->expects($this->at(0))->method('get')->with($this->equalTo('sulu_event.event_manager'))->will($this->returnValue($this->eventManager)); $this->container->expects($this->at(1))->method('get')->with($this->equalTo('massive_search.search_manager'))->will($this->returnValue($this->searchManager)); $eventMock = $this->getMock(Event::class); $eventMock->expects($this->any())->method('getTitle')->will($this->returnValue('FooBarEvent')); $eventMocks = array($eventMock); $this->eventManager->expects($this->once())->method('findAll')->will($this->returnValue($eventMocks)); $this->searchManager->expects($this->exactly(1))->method('index')->with($eventMock)->willThrowException(new \Exception('Something went wrong!')); $this->output->expects($this->at(1))->method('writeln')->with($this->stringContains('(path: FooBarEvent: Something went wrong!')); $reindexCommand = new ReindexCommand(); $reindexCommand->setContainer($this->container); $reindexCommand->execute($this->input, $this->output); }
public function testItDisplaysTheStatusForAllReturnedProducts() { $this->mockProductStatusAdapter->method('getStatusForProductsMatchingSku')->willReturn(['test1' => ProductStatusAdapterInterface::ENABLED, 'test2' => ProductStatusAdapterInterface::DISABLED]); $this->mockOutput->expects($this->exactly(2))->method('writeln')->withConsecutive([$this->stringContains('Status of product "test1": ' . ProductStatusAdapterInterface::ENABLED)], [$this->stringContains('Status of product "test2": ' . ProductStatusAdapterInterface::DISABLED)]); $this->command->run($this->mockInput, $this->mockOutput); }
public function testLogMeta() { $this->console->expects($this->once())->method('writeln')->with('<metadata>Meta message.</metadata>'); $this->consoleLoggerModel->logMeta('Meta message.'); }
/** * @dataProvider getGetMethods * * @param string $method * @param string $data */ public function testGetVerbosity($method, $data) { $this->output->expects($this->once())->method($method)->will($this->returnValue($data)); $this->assertEquals($data, call_user_func([$this->decorator, $method])); }
/** * Test quietness * * @dataProvider dataQuietness */ public function testQuietness($quiet, $countWriteln) { $this->input->expects($this->any())->method('getOption')->will($this->returnValueMap(array(array('quiet', $quiet)))); $this->output->expects($countWriteln)->method('writeln'); $this->command->setGearmanClient($this->gearmanClient)->setKernel($this->kernel)->run($this->input, $this->output); }
/** * Test run without quietness */ public function testRunNonQuiet() { $this->input->expects($this->any())->method('getOption')->will($this->returnValueMap(array(array('quiet', false)))); $this->output->expects($this->any())->method('writeln'); $this->command->run($this->input, $this->output); }
/** * Write messages. * * @param string[] $messages */ protected function write(array $messages) { foreach ($messages as $key => $message) { $this->output->expects($this->at($key + 1))->method('writeln')->with($message); } }