aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/config.yml1
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php4
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php23
-rw-r--r--tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php8
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json4
5 files changed, 33 insertions, 7 deletions
diff --git a/app/config/config.yml b/app/config/config.yml
index 04d757c1..0c2b6a1d 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -26,7 +26,6 @@ framework:
26 engines: ['twig'] 26 engines: ['twig']
27 default_locale: "%locale%" 27 default_locale: "%locale%"
28 trusted_hosts: ~ 28 trusted_hosts: ~
29 trusted_proxies: ~
30 session: 29 session:
31 # handler_id set to null will use default session handler from php.ini 30 # handler_id set to null will use default session handler from php.ini
32 handler_id: session.handler.native_file 31 handler_id: session.handler.native_file
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 9c9452dd..f91cdf5e 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -85,6 +85,10 @@ class DownloadImages
85 */ 85 */
86 public function processSingleImage($entryId, $imagePath, $url, $relativePath = null) 86 public function processSingleImage($entryId, $imagePath, $url, $relativePath = null)
87 { 87 {
88 if (null === $imagePath) {
89 return false;
90 }
91
88 if (null === $relativePath) { 92 if (null === $relativePath) {
89 $relativePath = $this->getRelativePath($entryId); 93 $relativePath = $this->getRelativePath($entryId);
90 } 94 }
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
index 51ab1bcd..faa803fa 100644
--- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -204,4 +204,27 @@ 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 testProcessImageWithNullPath()
209 {
210 $client = new Client();
211
212 $mock = new Mock([
213 new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
214 ]);
215
216 $client->getEmitter()->attach($mock);
217
218 $logHandler = new TestHandler();
219 $logger = new Logger('test', [$logHandler]);
220
221 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
222
223 $res = $download->processSingleImage(
224 123,
225 null,
226 'https://framablog.org/2018/06/30/engagement-atypique/'
227 );
228 $this->assertFalse($res);
229 }
207} 230}
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
index dc9d9a8f..fc02c813 100644
--- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
@@ -128,14 +128,14 @@ class FirefoxControllerTest extends WallabagCoreTestCase
128 ->get('doctrine.orm.entity_manager') 128 ->get('doctrine.orm.entity_manager')
129 ->getRepository('WallabagCoreBundle:Entry') 129 ->getRepository('WallabagCoreBundle:Entry')
130 ->findByUrlAndUserId( 130 ->findByUrlAndUserId(
131 'https://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', 131 'https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html',
132 $this->getLoggedInUserId() 132 $this->getLoggedInUserId()
133 ); 133 );
134 134
135 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 135 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
136 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://stackoverflow.com is ok'); 136 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.lemonde.fr is ok');
137 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://stackoverflow.com is ok'); 137 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.lemonde.fr is ok');
138 $this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok'); 138 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.lemonde.fr is ok');
139 139
140 $createdAt = $content->getCreatedAt(); 140 $createdAt = $content->getCreatedAt();
141 $this->assertSame('2013', $createdAt->format('Y')); 141 $this->assertSame('2013', $createdAt->format('Y'));
diff --git a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json
index 406b5697..3d90b489 100644
--- a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json
+++ b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json
@@ -39,13 +39,13 @@
39 }, 39 },
40 { 40 {
41 "guid": "E385l9vZ_LVn", 41 "guid": "E385l9vZ_LVn",
42 "title": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java", 42 "title": "Le journaliste et cinéaste Claude Lanzmann est mort",
43 "index": 1, 43 "index": 1,
44 "dateAdded": 1388166091544000, 44 "dateAdded": 1388166091544000,
45 "lastModified": 1388166091545000, 45 "lastModified": 1388166091545000,
46 "id": 5, 46 "id": 5,
47 "type": "text/x-moz-place", 47 "type": "text/x-moz-place",
48 "uri": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" 48 "uri": "https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html"
49 } 49 }
50 ] 50 ]
51 }, 51 },