本文整理汇总了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];
}