X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FImportBundle%2FController%2FPinboardControllerTest.php;h=80819f45757f4699dcdd09b6f24e8dab843ae266;hb=2a1ceb67b4400f46f4d3067e887ff54aa906f0a2;hp=75a7e332f3206596e06292738b2ba656196c7080;hpb=f17b89fadce0a8c2280fbe1518d66f20dddce59d;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 75a7e332..80819f45 100644 --- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php @@ -2,8 +2,8 @@ namespace Tests\Wallabag\ImportBundle\Controller; -use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; use Symfony\Component\HttpFoundation\File\UploadedFile; +use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; class PinboardControllerTest extends WallabagCoreTestCase { @@ -14,9 +14,9 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); - $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + $this->assertSame(200, $client->getResponse()->getStatusCode()); + $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertSame(1, $crawler->filter('input[type=file]')->count()); } public function testImportPinboardWithRabbitEnabled() @@ -28,9 +28,9 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); - $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + $this->assertSame(200, $client->getResponse()->getStatusCode()); + $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertSame(1, $crawler->filter('input[type=file]')->count()); $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); } @@ -49,7 +49,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertSame(200, $client->getResponse()->getStatusCode()); } public function testImportPinboardWithRedisEnabled() @@ -61,13 +61,13 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); - $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + $this->assertSame(200, $client->getResponse()->getStatusCode()); + $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertSame(1, $crawler->filter('input[type=file]')->count()); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); + $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json'); $data = [ 'upload_import_file[file]' => $file, @@ -75,7 +75,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); @@ -95,7 +95,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); + $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json'); $data = [ 'upload_import_file[file]' => $file, @@ -103,7 +103,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); @@ -118,12 +118,19 @@ class PinboardControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains('flashes.import.notice.summary', $body[0]); + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); $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(2, 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->assertSame(3, \count($tags)); + $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); - $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); + $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); } public function testImportPinboardWithFileAndMarkAllAsRead() @@ -134,7 +141,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard-read.json'); + $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard-read.json'); $data = [ 'upload_import_file[file]' => $file, @@ -143,7 +150,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); @@ -155,6 +162,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $this->getLoggedInUserId() ); + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content1); $this->assertTrue($content1->isArchived()); $content2 = $client->getContainer() @@ -165,6 +173,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $this->getLoggedInUserId() ); + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content2); $this->assertTrue($content2->isArchived()); $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); @@ -179,7 +188,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/pinboard'); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); + $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt'); $data = [ 'upload_import_file[file]' => $file, @@ -187,7 +196,7 @@ class PinboardControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect();