本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createKernel方法的典型用法代码示例。如果您正苦于以下问题:PHP WebTestCase::createKernel方法的具体用法?PHP WebTestCase::createKernel怎么用?PHP WebTestCase::createKernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Test\WebTestCase
的用法示例。
在下文中一共展示了WebTestCase::createKernel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommand
protected function getCommand()
{
$kernel = WebTestCase::createKernel();
$application = new Application($kernel);
$adapter = new SymfonyFinder();
$application->add(new FindCommand($adapter));
return $application->find('fsearch:find');
}
示例2: createKernel
/**
* {@inheritDoc}
*
* This is overriden to set the default environment to 'rctest'
*/
protected static function createKernel(array $options = array())
{
// default environment is 'rctest'
if (!isset($options['environment'])) {
$options['environment'] = 'default.yml';
}
return parent::createKernel($options);
}
示例3: runCommand
public function runCommand(Client $client, $command)
{
$application = new Application(WebTestCase::createKernel());
$application->setAutoExit(false);
$fp = tmpfile();
$input = new StringInput($command);
$output = new StreamOutput($fp);
$application->run($input, $output);
fseek($fp, 0);
$output = '';
while (!feof($fp)) {
$output = fread($fp, 4096);
}
fclose($fp);
return $output;
}
示例4: createKernel
/**
* {@inheritdoc}
*/
protected static function createKernel(array $options = array())
{
global $_SERVER;
// "MONOLITH_TEST_SUITE" variable can be set by a script which initiates running tests to signal
// that this is a monolith repository, that is - the repository contains functional tests
// for different bundles and in scope of one test run there's a chance that many app kernel instances
// will be instantiated and as result we want to avoid in-memory caching (this is what original
// "createClient" method actually does). In-memory caching speeds up test run but at the same
// time might in case of monolithic repositories will lead to re-using of wrong app kernels
$isMonolithTestSuite = isset($_SERVER['MONOLITH_TEST_SUITE']) && $_SERVER['MONOLITH_TEST_SUITE'];
if ($isMonolithTestSuite) {
static::$class = static::getKernelClass();
return new static::$class(isset($options['environment']) ? $options['environment'] : 'test', isset($options['debug']) ? $options['debug'] : true);
} else {
// letting to use runtime-caching
return parent::createKernel($options);
}
}