diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index acc39997..25625c35 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,22 @@ 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->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty'); |
130 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); | 123 | $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is empty'); |
131 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); | 124 | $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); |
132 | $this->assertEquals(1, count($content->getTags())); | 125 | |
126 | $tags = $content->getTags(); | ||
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | ||
128 | $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag'); | ||
129 | $this->assertSame(2, count($tags)); | ||
130 | |||
133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 131 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
134 | } | 132 | } |
135 | 133 | ||
@@ -141,7 +139,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
141 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 139 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
142 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 140 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
143 | 141 | ||
144 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); | 142 | $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); |
145 | 143 | ||
146 | $data = [ | 144 | $data = [ |
147 | 'upload_import_file[file]' => $file, | 145 | 'upload_import_file[file]' => $file, |
@@ -150,7 +148,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
150 | 148 | ||
151 | $client->submit($form, $data); | 149 | $client->submit($form, $data); |
152 | 150 | ||
153 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 151 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
154 | 152 | ||
155 | $crawler = $client->followRedirect(); | 153 | $crawler = $client->followRedirect(); |
156 | 154 | ||
@@ -186,7 +184,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
186 | $crawler = $client->request('GET', '/import/wallabag-v1'); | 184 | $crawler = $client->request('GET', '/import/wallabag-v1'); |
187 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 185 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
188 | 186 | ||
189 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | 187 | $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt'); |
190 | 188 | ||
191 | $data = [ | 189 | $data = [ |
192 | 'upload_import_file[file]' => $file, | 190 | 'upload_import_file[file]' => $file, |
@@ -194,7 +192,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
194 | 192 | ||
195 | $client->submit($form, $data); | 193 | $client->submit($form, $data); |
196 | 194 | ||
197 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 195 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
198 | 196 | ||
199 | $crawler = $client->followRedirect(); | 197 | $crawler = $client->followRedirect(); |
200 | 198 | ||