当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getContainer方法代码示例

本文整理汇总了PHP中Symfony\Component\BrowserKit\Client::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getContainer方法的具体用法?PHP Client::getContainer怎么用?PHP Client::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\BrowserKit\Client的用法示例。


在下文中一共展示了Client::getContainer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Set up the test
  */
 public function setUp()
 {
     $this->client = static::createClient(array(), array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'admin'));
     $this->em = $this->client->getContainer()->get('doctrine')->getManager();
     $this->jobTitle = $this->em->getRepository('OpitOpitHrmUserBundle:JobTitle')->findOneByTitle('CEO');
     $this->group = $this->em->getRepository('OpitOpitHrmUserBundle:Groups')->findOneByRole('ROLE_FINANCE');
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:10,代码来源:AdminUserControllerTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->db('ORM')->purgeDatabase();
     $this->client = $this->createAuthenticatedClient();
     $this->searchManager = $this->client->getContainer()->get('massive_search.search_manager');
     $this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $this->createUser();
     $this->indexProducts();
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:10,代码来源:SearchControllerTest.php

示例3: setUp

 /**
  * Set up the test
  */
 public function setUp()
 {
     $this->client = static::createClient(array(), array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'admin'));
     $this->em = $this->client->getContainer()->get('doctrine')->getManager();
     $adminUser = $this->em->getRepository('OpitOpitHrmUserBundle:User')->findOneByUsername('admin');
     $adminUser->setIsFirstLogin(false);
     $this->em->persist($adminUser);
     $this->em->flush();
     $this->perDiem = $this->em->getRepository('OpitOpitHrmTravelBundle:TEPerDiem')->findOneByHours('8');
     $this->expenseType = $this->em->getRepository('OpitOpitHrmTravelBundle:TEExpenseType')->findOneByName('Other');
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:14,代码来源:AdminControllerTest.php

示例4: logIn

 public function logIn(Client $client)
 {
     $session = $client->getContainer()->get('session');
     $firewall = 'admin';
     $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_USER'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
开发者ID:saro0h,项目名称:sf2c2,代码行数:10,代码来源:AbstractTest.php

示例5: authorizeClient

 /**
  * Create authorized client
  *
  * @link http://stackoverflow.com/questions/14957807/symfony2-tests-with-fosuserbundle/27223293#27223293
  * @return Client
  */
 public static function authorizeClient(Client $client)
 {
     $container = $client->getContainer();
     $session = $container->get('session');
     /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
     $userManager = $container->get('fos_user.user_manager');
     /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
     $loginManager = $container->get('fos_user.security.login_manager');
     $firewallName = $container->getParameter('fos_user.firewall_name');
     /// @todo create fixture for this
     $testUser = $container->getParameter('test_user');
     $user = $userManager->findUserBy(array('username' => $testUser));
     $loginManager->loginUser($firewallName, $user);
     // save the login token into the session and put it in a cookie
     $token = $container->get('security.context')->getToken();
     $session->set('_security_' . $firewallName, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
     return $client;
 }
开发者ID:hikmahtiar6,项目名称:drafterbit,代码行数:27,代码来源:WebTestCase.php

示例6: setUp

 /**
  * Set up the testing
  */
 public function setUp()
 {
     $this->client = static::createClient();
     $this->em = $this->client->getContainer()->get('doctrine')->getManager();
     $this->user = $this->em->getRepository('OpitOpitHrmUserBundle:User')->findOneByUsername('admin');
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:9,代码来源:UserRepositoryFunctionalTest.php


注:本文中的Symfony\Component\BrowserKit\Client::getContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。