當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::getContainer方法代碼示例

本文整理匯總了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());
 }
開發者ID:stopfstedt,項目名稱:ilios,代碼行數:7,代碼來源:AbstractControllerTest.php

示例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);
 }
開發者ID:keboola,項目名稱:syrup,代碼行數:25,代碼來源:ErrorHandlingTest.php

示例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);
 }
開發者ID:asev,項目名稱:SettingsBundle,代碼行數:10,代碼來源:PersonalSettingWidgetExtensionTest.php

示例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();
 }
開發者ID:bzis,項目名稱:zomba,代碼行數:7,代碼來源:TestCase.php

示例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')));
 }
開發者ID:xxspartan16,項目名稱:BMS-Market,代碼行數:8,代碼來源:PHPCRBlockLoaderTest.php

示例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();
 }
開發者ID:Newman101,項目名稱:WellCommerce,代碼行數:11,代碼來源:AbstractTestCase.php

示例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));
 }
開發者ID:keboola,項目名稱:google-analytics-bundle,代碼行數:8,代碼來源:MailerTest.php

示例8: setUp

 protected function setUp()
 {
     if (!self::$container) {
         self::$client = static::createClient();
         self::$container = self::$client->getContainer();
         //            self::loginAsUser();
     }
 }
開發者ID:Gemorroj,項目名稱:forum,代碼行數:8,代碼來源:ForumWebTestCase.php

示例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();
 }
開發者ID:llvdl,項目名稱:DominoSymfony,代碼行數:9,代碼來源:MockeryWebTestCase.php

示例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');
     }
 }
開發者ID:ubermichael,項目名稱:symftest,代碼行數:9,代碼來源:LOMWebTestCase.php

示例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');
 }
開發者ID:Reallymute,項目名稱:IRMApplicative,代碼行數:9,代碼來源:CarmaWebTestCase.php

示例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());
 }
開發者ID:ajouve,項目名稱:doctrine-fixtures-test,代碼行數:9,代碼來源:FixtureTestCase.php

示例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;
 }
開發者ID:avelov,項目名稱:techery_friends,代碼行數:13,代碼來源:AbstractTesting.php

示例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);
 }
開發者ID:Nemrtvej,項目名稱:symfony-template,代碼行數:13,代碼來源:ApplicationAvailabilityFunctionalTest.php

示例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);
 }
開發者ID:philipsorst,項目名稱:ddr-symfony-stack.php,代碼行數:13,代碼來源:BaseIntegrationTest.php


注:本文中的Symfony\Bundle\FrameworkBundle\Client::getContainer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。