當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。