本文整理汇总了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');
}
示例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();
}
示例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');
}
示例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);
}
示例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;
}
示例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');
}