本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getContainer方法的具体用法?PHP Client::getContainer怎么用?PHP Client::getContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::getContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->client = static::createClient();
$this->client->followRedirects();
$this->container = $this->client->getContainer();
$this->loadFixtures($this->getFixtures());
}
示例2: testControllerNoticeToException
public function testControllerNoticeToException()
{
$this->client = $this->createClient();
$errorOccured = false;
$syslogProcessorMock = $this->getMockBuilder('Keboola\\Syrup\\Monolog\\Processor\\SyslogProcessor')->disableOriginalConstructor()->getMock();
$syslogProcessorMock->expects($this->any())->method("processRecord")->with($this->callback(function ($subject) use(&$errorOccured) {
if ($subject['message'] == 'Notice: Undefined offset: 3') {
$e = $subject['context']['exception'];
$errorOccured = true;
return $e instanceof \Symfony\Component\Debug\Exception\ContextErrorException;
}
return true;
}))->willReturn(['level' => 100]);
$container = $this->client->getContainer();
$container->set('syrup.monolog.syslog_processor', $syslogProcessorMock);
$this->client->request('GET', '/tests/notice');
$response = $this->client->getResponse();
$responseJson = json_decode($response->getContent(), true);
$this->assertEquals('error', $responseJson['status']);
$this->assertEquals('Application error', $responseJson['error']);
$this->assertEquals(500, $responseJson['code']);
$this->assertArrayHasKey('exceptionId', $responseJson);
$this->assertArrayHasKey('runId', $responseJson);
$this->assertTrue($errorOccured);
}
示例3: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->twig = $this->client->getContainer()->get('twig');
$this->loginHelper = new LoginTestHelper($this->client);
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
static::$client = static::createClient();
static::$router = self::$client->getContainer()->get('router');
static::$em = self::$client->getContainer()->get('doctrine.orm.entity_manager');
static::$container = self::getContainer();
}
示例5: testGetUnpublished
public function testGetUnpublished()
{
/** @var $service PhpcrBlockLoader */
$service = $this->client->getContainer()->get('cmf.block.service');
$this->assertInstanceOf('Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock', $service->load(array('name' => '/test/blocks/block-1')));
// this block is not published, should be empty
$this->assertInstanceOf('Sonata\BlockBundle\Model\EmptyBlock', $service->load(array('name' => '/test/blocks/block-2')));
}
示例6: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->client = static::createClient();
$this->container = $this->client->getContainer();
$this->em = $this->container->get('doctrine')->getManager();
$this->validator = $this->container->get('validator');
$this->setCurrentShop();
}
示例7: setUp
protected function setUp()
{
static::$client = static::createClient();
$container = static::$client->getContainer();
$sapiToken = $container->getParameter('storage_api.test.token');
$sapiUrl = $container->getParameter('storage_api.test.url');
static::$client->setServerParameters(array('HTTP_X-StorageApi-Token' => $sapiToken));
}
示例8: setUp
protected function setUp()
{
if (!self::$container) {
self::$client = static::createClient();
self::$container = self::$client->getContainer();
// self::loginAsUser();
}
}
示例9: tearDown
public function tearDown()
{
foreach ($this->client->getContainer()->getMockedServices() as $id => $service) {
$this->client->getContainer()->unmock($id);
}
\Mockery::close();
$this->client = null;
parent::tearDown();
}
示例10: setUp
public function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->client->restart();
if ($this->logger === null) {
$this->logger = $this->client->getContainer()->get('monolog.logger.devel');
}
}
示例11: 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');
}
示例12: executeCommand
private function executeCommand(Command $command, Input $input)
{
$command->setApplication($this->application);
$input->setInteractive(false);
if ($command instanceof ContainerAwareCommand) {
$command->setContainer($this->client->getContainer());
}
$command->run($input, new NullOutput());
}
示例13: 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;
}
示例14: signInAsAdmin
/**
*
*/
protected function signInAsAdmin()
{
$session = $this->client->getContainer()->get('session');
$firewall = 'main';
$token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
$session->set('_security_' . $firewall, serialize($token));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());
$this->client->getCookieJar()->set($cookie);
}
示例15: logIn
/**
* @param User $user
*/
protected function logIn(User $user)
{
$session = $this->client->getContainer()->get('session');
$firewall = 'main';
$token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
$session->set('_security_' . $firewall, serialize($token));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());
$this->client->getCookieJar()->set($cookie);
}