本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::expects方法的具體用法?PHP OutputInterface::expects怎麽用?PHP OutputInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testItDisplaysAConfirmationMessageIfThereWasNoException
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);
}
示例2: testItDisplaysAMessageIfThereAreNoMatches
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);
}
示例3: testItDisplaysAConfirmationMessage
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);
}
示例4: testRunWithDefaultValues
public function testRunWithDefaultValues()
{
$this->output->expects(self::atLeastOnce())->method('writeln');
$input = new ArgvInput(array());
$actual = $this->sut->run($input, $this->output);
self::assertEmpty($actual);
}
示例5: testLogWithTags
/**
* @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);
}
示例6: testRemoveModulesFromDeploymentConfig
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']);
}
示例7: testUninstallCode
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']);
}
示例8: testUninstallRemoveCode
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']);
}
示例9: testWrite
/**
* @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));
}
示例10: testWriteLnLazy
/**
* @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();
}
示例11: testQuietness
/**
* 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);
}
示例12: testRegenerateStatic
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);
}
示例13: testCtagDevModeFalse
/**
* 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');
}
示例14: testItLogsToOutputIfAnExceptionIsThrownDuringIndexing
/**
* 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);
}
示例15: testItDisplaysTheStatusForAllReturnedProducts
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);
}