本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::getKernel方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getKernel方法的具体用法?PHP Client::getKernel怎么用?PHP Client::getKernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::getKernel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runCommand
protected function runCommand($command)
{
$command = sprintf('%s --quiet', $command);
$application = new Application($this->client->getKernel());
$application->setAutoExit(false);
return $application->run(new StringInput($command));
}
示例2: setUp
public function setUp()
{
$this->client = $this->createClient();
$this->app = new Application($this->client->getKernel());
$this->app->setAutoExit(false);
$this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
$this->router = static::$kernel->getContainer()->get('router');
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->client->followRedirects();
$this->kern = $this->client->getKernel();
$this->container = $this->client->getContainer();
$this->em = $this->container->get('doctrine.orm.entity_manager');
}
示例4: runCommand
protected function runCommand(array $arguments = [])
{
$application = new Application($this->client->getKernel());
$application->setAutoExit(false);
$arguments['--quiet'] = true;
$arguments['-e'] = 'test';
$input = new ArrayInput($arguments);
$application->run($input, new ConsoleOutput());
}
示例5: getClient
/**
* Creates if needed and returns client instance
*
* @param bool $reinitialize
* @param array $options
*
* @return Client
*/
protected static function getClient($reinitialize = false, array $options = [])
{
if (!static::$client || $reinitialize) {
static::$client = static::createClient($options);
}
// core is loaded (for tests without calling of getClient(true))
static::$client->getKernel()->boot();
return static::$client;
}
示例6: getInitClient
/**
* @return \Symfony\Bundle\FrameworkBundle\Client
*/
protected static function getInitClient()
{
if (self::$client) {
return self::$client;
}
self::$client = self::createClient();
static::$kernel = self::$client->getKernel();
self::$container = self::$client->getContainer();
return self::$client;
}
示例7: setUp
public function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->application = new Application($this->client->getKernel());
$this->application->setAutoExit(false);
$this->executeCommand(new CreateDatabaseDoctrineCommand(), new ArrayInput([]));
$this->executeCommand(new MigrationsMigrateDoctrineCommand(), new ArrayInput([]));
$this->executeCommand(new LoadDataFixturesDoctrineCommand(), new ArrayInput([]));
}
示例8: setUp
/**
* Setup HTTP client, command runner and Storage API client for each test
*/
protected function setUp()
{
$this->httpClient = static::createClient();
$container = $this->httpClient->getContainer();
if (!$this->storageApiToken) {
$this->storageApiToken = $container->getParameter('storage_api.test.token');
}
$this->httpClient->setServerParameters(['HTTP_X-StorageApi-Token' => $this->storageApiToken]);
$this->jobMapper = $container->get('syrup.elasticsearch.current_component_job_mapper');
$application = new Application($this->httpClient->getKernel());
$application->add(new JobCommand());
$command = $application->find('syrup:run-job');
$this->commandTester = new CommandTester($command);
$this->storageApiClient = new StorageApiClient(['token' => $this->storageApiToken, 'url' => $container->getParameter('storage_api.test.url')]);
}
示例9: runCommand
/**
* Runs a command and returns it output
*/
public function runCommand(Client $client, $command)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$input = new StringInput($command);
$output = new StreamOutput(fopen('php://memory', 'w', false));
$statusCode = $application->run($input, $output);
rewind($output->getStream());
$result = stream_get_contents($output->getStream());
return array($statusCode, $result);
}
示例10: setUp
protected function setUp()
{
static::$kernel = static::createKernel();
static::$kernel->boot();
$container = static::$kernel->getContainer();
$this->em = $container->get('doctrine')->getManager();
$this->locale = $container->getParameter('locale');
$this->secondLocale = array_values(array_diff($container->getParameter('locale_support'), [$this->locale]))[0];
$this->router = $container->get('router');
$this->sampleObjectLoader = $container->get('ojs_core.sample.object_loader');
$baseUrl = $container->getParameter('base_host');
$this->client = static::makeClient(array(), array('HTTP_HOST' => $baseUrl));
$this->app = new Application($this->client->getKernel());
$this->app->setAutoExit(false);
$isPhpunitFastest = getenv('ENV_TEST_IS_FIRST_ON_CHANNEL');
if ($isPhpunitFastest !== false) {
return;
}
if (!$this->useCachedDatabase()) {
$this->databaseInit();
}
}
示例11: setUp
public function setUp()
{
/** @var \Symfony\Bundle\FrameworkBundle\Client client */
$this->client = static::createClient();
$this->em = $this->client->getKernel()->getContainer()->get('doctrine')->getManager();
$this->url = $this->client->getKernel()->getContainer()->getParameter('domain');
$this->client_id = $this->client->getKernel()->getContainer()->getParameter('client_id');
$this->client_secret = $this->client->getKernel()->getContainer()->getParameter('client_secret');
$this->client_username = $this->client->getKernel()->getContainer()->getParameter('client_test_username');
$this->client_password = $this->client->getKernel()->getContainer()->getParameter('client_test_password');
$this->oAuthLogin();
}
示例12: runCommand
public function runCommand(Client $client, $command)
{
$application = new Application($client->getKernel());
$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, 1024 * 1024);
}
fclose($fp);
return $output;
}
示例13: execute
/**
* @return $this
*/
public function execute()
{
$this->client->disableReboot();
$this->client->getKernel()->shutdown();
$this->client->getKernel()->boot();
$event = new RequestHelperEvent($this);
$event->setBody($this->body);
$this->eventDispatcher->dispatch(static::EVENT_PRE_REQUEST, $event);
$this->client->request($this->method, $this->uri, $this->parameters, $this->files, $this->servers, $event->getBody());
$this->eventDispatcher->dispatch(static::EVENT_POST_REQUEST, new RequestHelperEvent($this));
// $this->eventDispatcher->dispatch(static::EVENT_ASSERT, new RequestHelperEvent($this));
foreach (array_filter($this->assertions) as $callback) {
call_user_func($callback, $this);
}
return $this;
}
示例14: setupUserRepositoryMock
/**
* @param $options
*/
public function setupUserRepositoryMock($options)
{
if (array_key_exists('user_repository', $options)) {
if (!array_key_exists('find_one_by', $options['user_repository'])) {
$calls = 2;
$callable = array($this, 'findOneBy');
} else {
$calls = $options['user_repository']['find_one_by']['calls'];
$callable = array($this, 'findOneByBis');
}
$mockBuilder = $this->getMockBuilder('WTW\\UserBundle\\Repository\\UserRepository')->disableOriginalConstructor()->disableAutoload();
$mock = $mockBuilder->setMethods(['findOneBy'])->getMock();
$mock->expects($this->exactly($calls))->method('findOneBy')->will($this->returnCallback($callable));
$this->client->getKernel()->getContainer()->set('wtw_user.repository.user', $mock);
}
}
示例15: runCommand
/**
* Runs a command and returns it output
*/
public function runCommand(Client $client, $command, $exceptionOnExitCode = true)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$input = new StringInput($command);
$output = new StreamOutput($fp = tmpfile());
$application->setCatchExceptions(false);
$return = $application->run($input, $output);
fseek($fp, 0);
$output = '';
while (!feof($fp)) {
$output .= fread($fp, 4096);
}
fclose($fp);
if ($exceptionOnExitCode && $return !== 0) {
throw new \RuntimeException(sprintf('Return code is not 0: %s', $output));
}
return $output;
}