Returns the kernel.
public getKernel ( ) : Symfony\Component\HttpKernel\HttpKernelInterface | ||
return | Symfony\Component\HttpKernel\HttpKernelInterface |
protected function runCommand($command) { $command = sprintf('%s --quiet', $command); $application = new Application($this->client->getKernel()); $application->setAutoExit(false); return $application->run(new StringInput($command)); }
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'); }
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'); }
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()); }
/** * 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; }
/** * @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; }
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([])); }
/** * 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')]); }
/** * 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); }
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(); } }
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(); }
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; }
/** * @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; }
/** * @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); } }
/** * 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; }
/** * Runs a command and returns it output. * * @param Client $client * @param string $command * @param int $verbosity Verbosity level to use. * @param int $exitCode Expected command exit code. * * @return string */ protected function runCommand(Client $client, $command, $verbosity = OutputInterface::VERBOSITY_NORMAL, $exitCode = 0) { $application = new Application($client->getKernel()); $application->setAutoExit(false); $fp = tmpfile(); $input = new StringInput($command); $output = new StreamOutput($fp); $output->setVerbosity($verbosity); $realCode = $application->run($input, $output); fseek($fp, 0); $output = ''; while (!feof($fp)) { $output = fread($fp, 4096); } fclose($fp); $this->assertEquals($exitCode, $realCode, $output); return $output; }
/** * Returns the kernel. * * @return KernelInterface */ public function getKernel() { return $this->subject->getKernel(); }
protected function getEntityManager(Client $client) { $kernel = $client->getKernel(); $kernel->boot(); return $kernel->getContainer()->get('doctrine')->getManager(); }