本文整理匯總了PHP中Symfony\Component\Console\Application::setConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::setConfig方法的具體用法?PHP Application::setConfig怎麽用?PHP Application::setConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::setConfig方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mockPipeCommands
public function mockPipeCommands(array $pipelineConfig, Application $app, array $expectedFinalConfig = [], $expectAnyCalls = false)
{
$app->setConfig($expectedFinalConfig);
$executionOrder = new \stdClass();
$executionOrder->order = [];
$mockedCommands = [];
foreach ($pipelineConfig as $command => $config) {
preg_match('/^([\\w:]+)(.*)/', $command, $match);
list($match, $commandName, $description) = $match;
$expectedFinalConfig = array_merge($expectedFinalConfig, $this->stripOutSpecialParams($config));
$artifactKey = $commandName . '_artifact';
$artifactValue = $commandName . '_artifact_value';
$expectedFinalConfig[$artifactKey] = $artifactValue;
if (!isset($mockedCommands[$commandName])) {
$mockedCommands[$commandName] = [$this->mockCommand($app, $commandName), []];
}
$mockCommand = $mockedCommands[$commandName][0];
$mockedCommands[$commandName][1][] = function () use($mockCommand, $artifactKey, $artifactValue, $commandName, &$executionOrder) {
$mockCommand->set($artifactKey, $artifactValue);
$executionOrder->order[] = $mockCommand->getName();
};
}
// lets aggregate all the calls to doExecute for each command
foreach ($mockedCommands as $mock) {
list($mockCommand, $doExecuteCallbacks) = $mock;
$mockCommand->expects($expectAnyCalls ? $this->any() : $this->exactly(count($doExecuteCallbacks)))->method('doExecute')->will($this->returnCallback(function () use($mockCommand, &$mockedCommands) {
$callback = array_shift($mockedCommands[$mockCommand->getName()][1]);
$callback();
}));
$app->add($mockCommand);
}
return [$executionOrder, $expectedFinalConfig];
}