aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php60
1 files changed, 37 insertions, 23 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index 26e2f40b..e52b9c85 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class WallabagV2ControllerTest extends WallabagCoreTestCase 8class WallabagV2ControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/wallabag-v2'); 15 $crawler = $client->request('GET', '/import/wallabag-v2');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportWallabagWithRabbitEnabled() 22 public function testImportWallabagWithRabbitEnabled()
@@ -28,9 +28,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/wallabag-v2'); 29 $crawler = $client->request('GET', '/import/wallabag-v2');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportWallabagWithRedisEnabled() 55 public function testImportWallabagWithRedisEnabled()
@@ -62,13 +62,13 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
62 62
63 $crawler = $client->request('GET', '/import/wallabag-v2'); 63 $crawler = $client->request('GET', '/import/wallabag-v2');
64 64
65 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 65 $this->assertSame(200, $client->getResponse()->getStatusCode());
66 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 66 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
67 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 67 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
68 68
69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
70 70
71 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); 71 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
72 72
73 $data = [ 73 $data = [
74 'upload_import_file[file]' => $file, 74 'upload_import_file[file]' => $file,
@@ -76,7 +76,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
76 76
77 $client->submit($form, $data); 77 $client->submit($form, $data);
78 78
79 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 79 $this->assertSame(302, $client->getResponse()->getStatusCode());
80 80
81 $crawler = $client->followRedirect(); 81 $crawler = $client->followRedirect();
82 82
@@ -96,7 +96,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
96 $crawler = $client->request('GET', '/import/wallabag-v2'); 96 $crawler = $client->request('GET', '/import/wallabag-v2');
97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
98 98
99 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); 99 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
100 100
101 $data = [ 101 $data = [
102 'upload_import_file[file]' => $file, 102 'upload_import_file[file]' => $file,
@@ -104,7 +104,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
104 104
105 $client->submit($form, $data); 105 $client->submit($form, $data);
106 106
107 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 107 $this->assertSame(302, $client->getResponse()->getStatusCode());
108 108
109 $crawler = $client->followRedirect(); 109 $crawler = $client->followRedirect();
110 110
@@ -119,10 +119,16 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
119 $this->getLoggedInUserId() 119 $this->getLoggedInUserId()
120 ); 120 );
121 121
122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); 122 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); 123
124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); 124 // empty because it wasn't re-imported
125 $this->assertEquals(0, count($content->getTags())); 125 $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is empty');
126 $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is empty');
127 $this->assertEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is empty');
128
129 $tags = $content->getTags();
130 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
131 $this->assertSame(1, count($tags));
126 132
127 $content = $client->getContainer() 133 $content = $client->getContainer()
128 ->get('doctrine.orm.entity_manager') 134 ->get('doctrine.orm.entity_manager')
@@ -132,12 +138,20 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
132 $this->getLoggedInUserId() 138 $this->getLoggedInUserId()
133 ); 139 );
134 140
141 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
135 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); 142 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok');
136 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); 143 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok');
137 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); 144 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok');
138 $this->assertEquals(2, count($content->getTags())); 145
146 $tags = $content->getTags();
147 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
148 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
149 $this->assertContains('blog', $tags, 'It includes the "blog" tag');
150 $this->assertSame(3, count($tags));
151
139 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 152 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
140 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 153 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
154 $this->assertTrue($content->isStarred(), 'Entry is starred');
141 } 155 }
142 156
143 public function testImportWallabagWithEmptyFile() 157 public function testImportWallabagWithEmptyFile()
@@ -148,7 +162,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
148 $crawler = $client->request('GET', '/import/wallabag-v2'); 162 $crawler = $client->request('GET', '/import/wallabag-v2');
149 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 163 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
150 164
151 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 165 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
152 166
153 $data = [ 167 $data = [
154 'upload_import_file[file]' => $file, 168 'upload_import_file[file]' => $file,
@@ -156,7 +170,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
156 170
157 $client->submit($form, $data); 171 $client->submit($form, $data);
158 172
159 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 173 $this->assertSame(302, $client->getResponse()->getStatusCode());
160 174
161 $crawler = $client->followRedirect(); 175 $crawler = $client->followRedirect();
162 176