From bad7df8c0048285e7a6bd539e5e501ce6675d663 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 31 May 2017 10:38:15 +0200 Subject: [PATCH] CS & improve tags assertions --- .../CoreBundle/Command/ExportCommandTest.php | 2 +- .../CoreBundle/Command/TagAllCommandTest.php | 2 +- .../CoreBundle/Helper/ContentProxyTest.php | 1 - .../UsernameRssTokenConverterTest.php | 2 +- .../Command/RedisWorkerCommandTest.php | 4 ++-- .../Controller/PinboardControllerTest.php | 8 +++++++- .../Controller/ReadabilityControllerTest.php | 6 +++++- .../Controller/WallabagV1ControllerTest.php | 14 ++++++-------- .../Controller/WallabagV2ControllerTest.php | 13 +++++++++++-- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php index b21f3318..284efac4 100644 --- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php @@ -10,7 +10,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; class ExportCommandTest extends WallabagCoreTestCase { /** - * @expectedException Symfony\Component\Console\Exception\RuntimeException + * @expectedException \Symfony\Component\Console\Exception\RuntimeException * @expectedExceptionMessage Not enough arguments (missing: "username") */ public function testExportCommandWithoutUsername() diff --git a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php index ec31708f..4cde3679 100644 --- a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php @@ -10,7 +10,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; class TagAllCommandTest extends WallabagCoreTestCase { /** - * @expectedException Symfony\Component\Console\Exception\RuntimeException + * @expectedException \Symfony\Component\Console\Exception\RuntimeException * @expectedExceptionMessage Not enough arguments (missing: "username") */ public function testRunTagAllCommandWithoutUsername() diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 77dfd5bf..44fca073 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php @@ -7,7 +7,6 @@ use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\UserBundle\Entity\User; -use Wallabag\CoreBundle\Repository\TagRepository; use Wallabag\CoreBundle\Helper\RuleBasedTagger; class ContentProxyTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php index 2e6fccfb..ca8e0d50 100644 --- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php +++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php @@ -136,7 +136,7 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @expectedExceptionMessage User not found */ public function testApplyUserNotFound() diff --git a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php index 74952847..e5e251a0 100644 --- a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php @@ -11,7 +11,7 @@ use M6Web\Component\RedisMock\RedisMockFactory; class RedisWorkerCommandTest extends WallabagCoreTestCase { /** - * @expectedException Symfony\Component\Console\Exception\RuntimeException + * @expectedException \Symfony\Component\Console\Exception\RuntimeException * @expectedExceptionMessage Not enough arguments (missing: "serviceName") */ public function testRunRedisWorkerCommandWithoutArguments() @@ -28,7 +28,7 @@ class RedisWorkerCommandTest extends WallabagCoreTestCase } /** - * @expectedException Symfony\Component\Config\Definition\Exception\Exception + * @expectedException \Symfony\Component\Config\Definition\Exception\Exception * @expectedExceptionMessage No queue or consumer found for service name */ public function testRunRedisWorkerCommandWithBadService() diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 96b32484..e2b6e7b6 100644 --- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php @@ -121,7 +121,13 @@ class PinboardControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); - $this->assertEquals(3, count($content->getTags())); + + $tags = $content->getTags(); + $this->assertContains('foot', $tags, 'It includes the "foot" tag'); + $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); + $this->assertContains('PHP', $tags, 'It includes the "PHP" tag'); + $this->assertEquals(3, count($tags)); + $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); } diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index e6d33fe9..bde0a600 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php @@ -121,7 +121,11 @@ class ReadabilityControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); - $this->assertEquals(1, count($content->getTags())); + + $tags = $content->getTags(); + $this->assertContains('foot', $tags, 'It includes the "foot" tag'); + $this->assertEquals(1, count($tags)); + $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); } diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index 0c7f97ed..4ca6e623 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php @@ -116,20 +116,18 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase $this->getLoggedInUserId() ); - $tag = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Tag') - ->findOneByLabel('Framabag'); - - $this->assertTrue($content->getTags()->contains($tag)); - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains('flashes.import.notice.summary', $body[0]); $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); - $this->assertEquals(2, count($content->getTags())); + + $tags = $content->getTags(); + $this->assertContains('foot', $tags, 'It includes the "foot" tag'); + $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag'); + $this->assertEquals(2, count($tags)); + $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); } diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index 335115fe..18a02522 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php @@ -122,7 +122,10 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); - $this->assertEquals(1, count($content->getTags())); + + $tags = $content->getTags(); + $this->assertContains('foot', $tags, 'It includes the "foot" tag'); + $this->assertEquals(1, count($tags)); $content = $client->getContainer() ->get('doctrine.orm.entity_manager') @@ -135,7 +138,13 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); - $this->assertEquals(3, count($content->getTags())); + + $tags = $content->getTags(); + $this->assertContains('foot', $tags, 'It includes the "foot" tag'); + $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); + $this->assertContains('blog', $tags, 'It includes the "blog" tag'); + $this->assertEquals(3, count($tags)); + $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); $this->assertTrue($content->isStarred(), 'Entry is starred'); -- 2.41.0