diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index acc39997..e0e309b0 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Controller; | 3 | namespace Tests\Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | 5 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
6 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
7 | 7 | ||
8 | class WallabagV1ControllerTest extends WallabagCoreTestCase | 8 | class WallabagV1ControllerTest extends WallabagCoreTestCase |
9 | { | 9 | { |
@@ -14,9 +14,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
14 | 14 | ||
15 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 15 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
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 WallabagV1ControllerTest extends WallabagCoreTestCase | |||
28 | 28 | ||
29 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 29 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
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 WallabagV1ControllerTest 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 WallabagV1ControllerTest extends WallabagCoreTestCase | |||
62 | 62 | ||
63 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 63 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
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-v1.json', 'wallabag-v1.json'); | 71 | $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); |
72 | 72 | ||
73 | $data = [ | 73 | $data = [ |
74 | 'upload_import_file[file]' => $file, | 74 | 'upload_import_file[file]' => $file, |
@@ -76,7 +76,7 @@ class WallabagV1ControllerTest 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 WallabagV1ControllerTest extends WallabagCoreTestCase | |||
96 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 96 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
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-v1.json', 'wallabag-v1.json'); | 99 | $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); |
100 | 100 | ||
101 | $data = [ | 101 | $data = [ |
102 | 'upload_import_file[file]' => $file, | 102 | 'upload_import_file[file]' => $file, |
@@ -104,7 +104,7 @@ class WallabagV1ControllerTest 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 | ||
@@ -112,24 +112,23 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
112 | ->get('doctrine.orm.entity_manager') | 112 | ->get('doctrine.orm.entity_manager') |
113 | ->getRepository('WallabagCoreBundle:Entry') | 113 | ->getRepository('WallabagCoreBundle:Entry') |
114 | ->findByUrlAndUserId( | 114 | ->findByUrlAndUserId( |
115 | 'https://framablog.org/2014/02/05/framabag-service-libre-gratuit-interview-developpeur/', | 115 | 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', |
116 | $this->getLoggedInUserId() | 116 | $this->getLoggedInUserId() |
117 | ); | 117 | ); |
118 | 118 | ||
119 | $tag = $client->getContainer() | ||
120 | ->get('doctrine.orm.entity_manager') | ||
121 | ->getRepository('WallabagCoreBundle:Tag') | ||
122 | ->findOneByLabel('Framabag'); | ||
123 | |||
124 | $this->assertTrue($content->getTags()->contains($tag)); | ||
125 | |||
126 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 119 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
127 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 120 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
128 | 121 | ||
129 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); | 122 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
130 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); | 123 | $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty'); |
131 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); | 124 | $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is empty'); |
132 | $this->assertEquals(1, count($content->getTags())); | 125 | $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); |
126 | |||
127 | $tags = $content->getTags(); | ||
128 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | ||
129 | $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); | ||
130 | $this->assertSame(2, count($tags)); | ||
131 | |||
133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
134 | } | 133 | } |
135 | 134 | ||
@@ -141,7 +140,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
141 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 140 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
142 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 141 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
143 | 142 | ||
144 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); | 143 | $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); |
145 | 144 | ||
146 | $data = [ | 145 | $data = [ |
147 | 'upload_import_file[file]' => $file, | 146 | 'upload_import_file[file]' => $file, |
@@ -150,7 +149,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
150 | 149 | ||
151 | $client->submit($form, $data); | 150 | $client->submit($form, $data); |
152 | 151 | ||
153 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 152 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
154 | 153 | ||
155 | $crawler = $client->followRedirect(); | 154 | $crawler = $client->followRedirect(); |
156 | 155 | ||
@@ -162,6 +161,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
162 | $this->getLoggedInUserId() | 161 | $this->getLoggedInUserId() |
163 | ); | 162 | ); |
164 | 163 | ||
164 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content1); | ||
165 | $this->assertTrue($content1->isArchived()); | 165 | $this->assertTrue($content1->isArchived()); |
166 | 166 | ||
167 | $content2 = $client->getContainer() | 167 | $content2 = $client->getContainer() |
@@ -172,6 +172,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
172 | $this->getLoggedInUserId() | 172 | $this->getLoggedInUserId() |
173 | ); | 173 | ); |
174 | 174 | ||
175 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content2); | ||
175 | $this->assertTrue($content2->isArchived()); | 176 | $this->assertTrue($content2->isArchived()); |
176 | 177 | ||
177 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 178 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
@@ -186,7 +187,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
186 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 187 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
187 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 188 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
188 | 189 | ||
189 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | 190 | $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt'); |
190 | 191 | ||
191 | $data = [ | 192 | $data = [ |
192 | 'upload_import_file[file]' => $file, | 193 | 'upload_import_file[file]' => $file, |
@@ -194,7 +195,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
194 | 195 | ||
195 | $client->submit($form, $data); | 196 | $client->submit($form, $data); |
196 | 197 | ||
197 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 198 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
198 | 199 | ||
199 | $crawler = $client->followRedirect(); | 200 | $crawler = $client->followRedirect(); |
200 | 201 | ||