diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index 7557ea32..933fffa2 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.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 FirefoxControllerTest extends WallabagCoreTestCase | 8 | class FirefoxControllerTest extends WallabagCoreTestCase |
9 | { | 9 | { |
@@ -14,9 +14,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
14 | 14 | ||
15 | $crawler = $client->request('GET', '/import/firefox'); | 15 | $crawler = $client->request('GET', '/import/firefox'); |
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 testImportFirefoxWithRabbitEnabled() | 22 | public function testImportFirefoxWithRabbitEnabled() |
@@ -28,9 +28,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
28 | 28 | ||
29 | $crawler = $client->request('GET', '/import/firefox'); | 29 | $crawler = $client->request('GET', '/import/firefox'); |
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 FirefoxControllerTest 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 testImportFirefoxWithRedisEnabled() | 55 | public function testImportFirefoxWithRedisEnabled() |
@@ -61,13 +61,13 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
61 | 61 | ||
62 | $crawler = $client->request('GET', '/import/firefox'); | 62 | $crawler = $client->request('GET', '/import/firefox'); |
63 | 63 | ||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 64 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
65 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | 65 | $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); |
66 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | 66 | $this->assertSame(1, $crawler->filter('input[type=file]')->count()); |
67 | 67 | ||
68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
69 | 69 | ||
70 | $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); | 70 | $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks'); |
71 | 71 | ||
72 | $data = [ | 72 | $data = [ |
73 | 'upload_import_file[file]' => $file, | 73 | 'upload_import_file[file]' => $file, |
@@ -75,7 +75,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
75 | 75 | ||
76 | $client->submit($form, $data); | 76 | $client->submit($form, $data); |
77 | 77 | ||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 78 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
79 | 79 | ||
80 | $crawler = $client->followRedirect(); | 80 | $crawler = $client->followRedirect(); |
81 | 81 | ||
@@ -95,7 +95,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
95 | $crawler = $client->request('GET', '/import/firefox'); | 95 | $crawler = $client->request('GET', '/import/firefox'); |
96 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 96 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
97 | 97 | ||
98 | $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); | 98 | $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks'); |
99 | 99 | ||
100 | $data = [ | 100 | $data = [ |
101 | 'upload_import_file[file]' => $file, | 101 | 'upload_import_file[file]' => $file, |
@@ -103,7 +103,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
103 | 103 | ||
104 | $client->submit($form, $data); | 104 | $client->submit($form, $data); |
105 | 105 | ||
106 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 106 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
107 | 107 | ||
108 | $crawler = $client->followRedirect(); | 108 | $crawler = $client->followRedirect(); |
109 | 109 | ||
@@ -118,26 +118,28 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
118 | $this->getLoggedInUserId() | 118 | $this->getLoggedInUserId() |
119 | ); | 119 | ); |
120 | 120 | ||
121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | ||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); |
124 | $this->assertEquals(2, count($content->getTags())); | 125 | $this->assertSame(3, count($content->getTags())); |
125 | 126 | ||
126 | $content = $client->getContainer() | 127 | $content = $client->getContainer() |
127 | ->get('doctrine.orm.entity_manager') | 128 | ->get('doctrine.orm.entity_manager') |
128 | ->getRepository('WallabagCoreBundle:Entry') | 129 | ->getRepository('WallabagCoreBundle:Entry') |
129 | ->findByUrlAndUserId( | 130 | ->findByUrlAndUserId( |
130 | 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', | 131 | 'https://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', |
131 | $this->getLoggedInUserId() | 132 | $this->getLoggedInUserId() |
132 | ); | 133 | ); |
133 | 134 | ||
134 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://stackoverflow.com is ok'); | 135 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
135 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://stackoverflow.com is ok'); | 136 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://stackoverflow.com is ok'); |
136 | $this->assertEmpty($content->getLanguage(), 'Language for http://stackoverflow.com is ok'); | 137 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://stackoverflow.com is ok'); |
138 | $this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok'); | ||
137 | 139 | ||
138 | $createdAt = $content->getCreatedAt(); | 140 | $createdAt = $content->getCreatedAt(); |
139 | $this->assertEquals('2013', $createdAt->format('Y')); | 141 | $this->assertSame('2013', $createdAt->format('Y')); |
140 | $this->assertEquals('12', $createdAt->format('m')); | 142 | $this->assertSame('12', $createdAt->format('m')); |
141 | } | 143 | } |
142 | 144 | ||
143 | public function testImportWallabagWithEmptyFile() | 145 | public function testImportWallabagWithEmptyFile() |
@@ -148,7 +150,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
148 | $crawler = $client->request('GET', '/import/firefox'); | 150 | $crawler = $client->request('GET', '/import/firefox'); |
149 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 151 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
150 | 152 | ||
151 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | 153 | $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt'); |
152 | 154 | ||
153 | $data = [ | 155 | $data = [ |
154 | 'upload_import_file[file]' => $file, | 156 | 'upload_import_file[file]' => $file, |
@@ -156,7 +158,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
156 | 158 | ||
157 | $client->submit($form, $data); | 159 | $client->submit($form, $data); |
158 | 160 | ||
159 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 161 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
160 | 162 | ||
161 | $crawler = $client->followRedirect(); | 163 | $crawler = $client->followRedirect(); |
162 | 164 | ||