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 ++++++++++++++++++++++ src/Wallabag/CoreBundle/Command/InstallCommand.php | 4 +- .../Tests/Controller/EntryControllerTest.php | 6 +++ .../Tests/EventListener/LocaleListenerTest.php | 3 +- .../RegistrationConfirmedListenerTest.php | 3 +- .../Tests/EventListener/UserLocaleListenerTest.php | 3 +- .../CoreBundle/Tests/Helper/ContentProxyTest.php | 3 +- .../UsernameRssTokenConverterTest.php | 3 +- .../Tests/Subscriber/TablePrefixSubscriberTest.php | 3 +- 11 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php create mode 100644 src/Wallabag/ApiBundle/Tests/WallabagApiTestCase.php (limited to 'src') 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; + } +} diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 865a73e1..8b702c95 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -96,10 +96,10 @@ class InstallCommand extends ContainerAwareCommand if (!$fulfilled) { throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.'); - } else { - $this->defaultOutput->writeln('Success! Your system can run Wallabag properly.'); } + $this->defaultOutput->writeln('Success! Your system can run Wallabag properly.'); + $this->defaultOutput->writeln(''); return $this; diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 5ac39d12..0bd7d4fe 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -74,6 +74,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals('This value should not be blank.', $alert[0]); } + /** + * This test will require an internet connection + */ public function testPostNewOk() { $this->logInAs('admin'); @@ -119,6 +122,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); } + /** + * @depends testPostNewOk + */ public function testView() { $this->logInAs('admin'); diff --git a/src/Wallabag/CoreBundle/Tests/EventListener/LocaleListenerTest.php b/src/Wallabag/CoreBundle/Tests/EventListener/LocaleListenerTest.php index 356a411e..d89bee04 100644 --- a/src/Wallabag/CoreBundle/Tests/EventListener/LocaleListenerTest.php +++ b/src/Wallabag/CoreBundle/Tests/EventListener/LocaleListenerTest.php @@ -2,7 +2,6 @@ namespace Wallabag\CoreBundle\Tests\EventListener; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\KernelEvents; @@ -12,7 +11,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Session; use Wallabag\CoreBundle\EventListener\LocaleListener; -class LocaleListenerTest extends KernelTestCase +class LocaleListenerTest extends \PHPUnit_Framework_TestCase { private function getEvent(Request $request) { diff --git a/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php b/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php index df94fad2..31283399 100644 --- a/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php +++ b/src/Wallabag/CoreBundle/Tests/EventListener/RegistrationConfirmedListenerTest.php @@ -2,7 +2,6 @@ namespace Wallabag\CoreBundle\Tests\EventListener; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -12,7 +11,7 @@ use Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener; use Wallabag\CoreBundle\Entity\Config; use Wallabag\UserBundle\Entity\User; -class RegistrationConfirmedListenerTest extends KernelTestCase +class RegistrationConfirmedListenerTest extends \PHPUnit_Framework_TestCase { private $em; private $listener; diff --git a/src/Wallabag/CoreBundle/Tests/EventListener/UserLocaleListenerTest.php b/src/Wallabag/CoreBundle/Tests/EventListener/UserLocaleListenerTest.php index e8a65fbf..80ddb457 100644 --- a/src/Wallabag/CoreBundle/Tests/EventListener/UserLocaleListenerTest.php +++ b/src/Wallabag/CoreBundle/Tests/EventListener/UserLocaleListenerTest.php @@ -2,7 +2,6 @@ namespace Wallabag\CoreBundle\Tests\EventListener; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Session; @@ -12,7 +11,7 @@ use Wallabag\CoreBundle\EventListener\UserLocaleListener; use Wallabag\CoreBundle\Entity\Config; use Wallabag\UserBundle\Entity\User; -class UserLocaleListenerTest extends KernelTestCase +class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase { public function testWithLanguage() { diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php index 1d0d4062..4bce4708 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php @@ -2,12 +2,11 @@ namespace Wallabag\CoreBundle\Tests\Helper; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Helper\ContentProxy; -class ContentProxyTest extends KernelTestCase +class ContentProxyTest extends \PHPUnit_Framework_TestCase { public function testWithEmptyContent() { diff --git a/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php b/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php index e28dc4ba..1c9a4ad7 100644 --- a/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php +++ b/src/Wallabag/CoreBundle/Tests/ParamConverter/UsernameRssTokenConverterTest.php @@ -2,13 +2,12 @@ namespace Wallabag\CoreBundle\Tests\Command; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\HttpFoundation\Request; use Wallabag\UserBundle\Entity\User; -class UsernameRssTokenConverterTest extends KernelTestCase +class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase { public function testSupportsWithNoRegistry() { diff --git a/src/Wallabag/CoreBundle/Tests/Subscriber/TablePrefixSubscriberTest.php b/src/Wallabag/CoreBundle/Tests/Subscriber/TablePrefixSubscriberTest.php index 4c138610..a26ff436 100644 --- a/src/Wallabag/CoreBundle/Tests/Subscriber/TablePrefixSubscriberTest.php +++ b/src/Wallabag/CoreBundle/Tests/Subscriber/TablePrefixSubscriberTest.php @@ -2,13 +2,12 @@ namespace Wallabag\CoreBundle\Tests\Subscriber; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\Common\EventManager; use Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber; -class TablePrefixSubscriberTest extends KernelTestCase +class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase { public function dataForPrefix() { -- cgit v1.2.3