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/AbstractControllerTest.php | 46 ---------------------- .../Controller/WallabagRestControllerTest.php | 4 +- .../ApiBundle/Tests/WallabagApiTestCase.php | 46 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php create mode 100644 src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php b/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php deleted file mode 100644 index 09cde0f6..00000000 --- a/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php +++ /dev/null @@ -1,46 +0,0 @@ -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; - } -} diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index bc7ef489..bdd36e0c 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -2,9 +2,9 @@ namespace Wallabag\ApiBundle\Tests\Controller; -use Wallabag\ApiBundle\Tests\AbstractControllerTest; +use Wallabag\ApiBundle\Tests\WallabagApiTestCase; -class WallabagRestControllerTest extends AbstractControllerTest +class WallabagRestControllerTest extends WallabagApiTestCase { protected static $salt; 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