From 8a493541fa4911233fe9186e88371d17cb9fd7db Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 1 Nov 2015 23:42:52 +0100 Subject: Re-enable test on doctrine command It will slow down the whole test suite (because it'll use doctrine command). Remove unecessary `KernelTestCase`. Also rename `AbstractControllerTest` to `WallabagApiTestCase` for consistency. --- .../ApiBundle/Tests/WallabagApiTestCase.php | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php (limited to 'src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php') diff --git a/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php b/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php new file mode 100644 index 00000000..8a57fea2 --- /dev/null +++ b/src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php @@ -0,0 +1,46 @@ +client = $this->createAuthorizedClient(); + } + + /** + * @return Client + */ + protected function createAuthorizedClient() + { + $client = static::createClient(); + $container = $client->getContainer(); + + /** @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'); + + $user = $userManager->findUserBy(array('username' => 'admin')); + $loginManager->loginUser($firewallName, $user); + + // save the login token into the session and put it in a cookie + $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken())); + $container->get('session')->save(); + + $session = $container->get('session'); + $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId())); + + return $client; + } +} -- cgit v1.2.3