diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-09-07 13:46:30 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-09-07 13:46:30 +0200 |
commit | 7083c0a21d27e7e1bf45a9807a76844116d61fb8 (patch) | |
tree | b72b5a0516d9114aeeccd6ecdb055ee240bda66a /tests/Wallabag/CoreBundle | |
parent | 44043ebe82a22470e2514d05efac324035ee809a (diff) | |
parent | 495f83c92539444bff7dfd6cd647b7d65a74f949 (diff) | |
download | wallabag-7083c0a21d27e7e1bf45a9807a76844116d61fb8.tar.gz wallabag-7083c0a21d27e7e1bf45a9807a76844116d61fb8.tar.zst wallabag-7083c0a21d27e7e1bf45a9807a76844116d61fb8.zip |
Merge remote-tracking branch 'origin/master' into 2.4
Diffstat (limited to 'tests/Wallabag/CoreBundle')
4 files changed, 52 insertions, 8 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a436be79..6a4c775b 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -524,7 +524,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
524 | 524 | ||
525 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 525 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); |
526 | $this->assertContains('My updated title hehe :)', $title[0]); | 526 | $this->assertContains('My updated title hehe :)', $title[0]); |
527 | $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); | 527 | $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); |
528 | $this->assertNotContains('example.io', trim($stats[0])); | 528 | $this->assertNotContains('example.io', trim($stats[0])); |
529 | } | 529 | } |
530 | 530 | ||
@@ -1325,10 +1325,6 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1325 | 'http://www.hao123.com/shequ?__noscript__-=1', | 1325 | 'http://www.hao123.com/shequ?__noscript__-=1', |
1326 | 'zh_CN', | 1326 | 'zh_CN', |
1327 | ], | 1327 | ], |
1328 | 'de_AT' => [ | ||
1329 | 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728', | ||
1330 | 'de_AT', | ||
1331 | ], | ||
1332 | 'ru_RU' => [ | 1328 | 'ru_RU' => [ |
1333 | 'http://netler.ru/ikt/windows-error-reporting.htm', | 1329 | 'http://netler.ru/ikt/windows-error-reporting.htm', |
1334 | 'ru_RU', | 1330 | 'ru_RU', |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index ab7f23cc..6f3308e5 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
180 | 180 | ||
181 | $this->assertGreaterThan(1, $csv); | 181 | $this->assertGreaterThan(1, $csv); |
182 | // +1 for title line | 182 | // +1 for title line |
183 | $this->assertSame(count($contentInDB) + 1, count($csv)); | 183 | $this->assertSame(\count($contentInDB) + 1, \count($csv)); |
184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); | 184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); |
185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); | 185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); |
186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); | 186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); |
@@ -272,7 +272,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
272 | 272 | ||
273 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); | 273 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); |
274 | $this->assertGreaterThan(0, $content->count()); | 274 | $this->assertGreaterThan(0, $content->count()); |
275 | $this->assertSame(count($contentInDB), $content->count()); | 275 | $this->assertSame(\count($contentInDB), $content->count()); |
276 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); | 276 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); |
277 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); | 277 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); |
278 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); | 278 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 5a973a7e..768f4c07 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -98,7 +98,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
98 | $tags[$key] = $tag->getLabel(); | 98 | $tags[$key] = $tag->getLabel(); |
99 | } | 99 | } |
100 | 100 | ||
101 | $this->assertGreaterThanOrEqual(2, count($tags)); | 101 | $this->assertGreaterThanOrEqual(2, \count($tags)); |
102 | $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry'); | 102 | $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry'); |
103 | $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry'); | 103 | $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry'); |
104 | } | 104 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php index 51ab1bcd..cda5f843 100644 --- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php +++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php | |||
@@ -204,4 +204,52 @@ class DownloadImagesTest extends TestCase | |||
204 | 204 | ||
205 | $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); | 205 | $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); |
206 | } | 206 | } |
207 | |||
208 | public function testProcessImageWithTrickySrcset() | ||
209 | { | ||
210 | $client = new Client(); | ||
211 | |||
212 | $mock = new Mock([ | ||
213 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
214 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
215 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
216 | ]); | ||
217 | |||
218 | $client->getEmitter()->attach($mock); | ||
219 | |||
220 | $logHandler = new TestHandler(); | ||
221 | $logger = new Logger('test', [$logHandler]); | ||
222 | |||
223 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); | ||
224 | $res = $download->processHtml(123, '<figure id="post-257260" class="align-none media-257260"><img src="https://cdn.css-tricks.com/wp-content/uploads/2017/08/the-critical-request.png" srcset="https://res.cloudinary.com/css-tricks/image/upload/c_scale,w_1000,f_auto,q_auto/v1501594717/the-critical-request_bqdfaa.png 1000w, https://res.cloudinary.com/css-tricks/image/upload/c_scale,w_200,f_auto,q_auto/v1501594717/the-critical-request_bqdfaa.png 200w" sizes="(min-width: 1850px) calc( (100vw - 555px) / 3 ) | ||
225 | (min-width: 1251px) calc( (100vw - 530px) / 2 ) | ||
226 | (min-width: 1086px) calc(100vw - 480px) | ||
227 | (min-width: 626px) calc(100vw - 335px) | ||
228 | calc(100vw - 30px)" alt="" /></figure>', 'https://css-tricks.com/the-critical-request/'); | ||
229 | |||
230 | $this->assertNotContains('f_auto,q_auto', $res, 'Image srcset attribute were not replaced'); | ||
231 | } | ||
232 | |||
233 | public function testProcessImageWithNullPath() | ||
234 | { | ||
235 | $client = new Client(); | ||
236 | |||
237 | $mock = new Mock([ | ||
238 | new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
239 | ]); | ||
240 | |||
241 | $client->getEmitter()->attach($mock); | ||
242 | |||
243 | $logHandler = new TestHandler(); | ||
244 | $logger = new Logger('test', [$logHandler]); | ||
245 | |||
246 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); | ||
247 | |||
248 | $res = $download->processSingleImage( | ||
249 | 123, | ||
250 | null, | ||
251 | 'https://framablog.org/2018/06/30/engagement-atypique/' | ||
252 | ); | ||
253 | $this->assertFalse($res); | ||
254 | } | ||
207 | } | 255 | } |