aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--composer.json2
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php41
4 files changed, 44 insertions, 3 deletions
diff --git a/composer.json b/composer.json
index fb6bed5b..b21c9538 100644
--- a/composer.json
+++ b/composer.json
@@ -84,7 +84,7 @@
84 "javibravo/simpleue": "^1.0", 84 "javibravo/simpleue": "^1.0",
85 "symfony/dom-crawler": "^3.1", 85 "symfony/dom-crawler": "^3.1",
86 "friendsofsymfony/jsrouting-bundle": "^1.6", 86 "friendsofsymfony/jsrouting-bundle": "^1.6",
87 "bdunogier/guzzle-site-authenticator": "^1.0@beta" 87 "bdunogier/guzzle-site-authenticator": "dev-master"
88 }, 88 },
89 "require-dev": { 89 "require-dev": {
90 "doctrine/doctrine-fixtures-bundle": "~2.2", 90 "doctrine/doctrine-fixtures-bundle": "~2.2",
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 0130bd2b..f222dd88 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -88,7 +88,7 @@ class ContentProxy
88 $entry->setDomainName($domainName); 88 $entry->setDomainName($domainName);
89 } 89 }
90 90
91 if (isset($content['open_graph']['og_image'])) { 91 if (isset($content['open_graph']['og_image']) && $content['open_graph']['og_image']) {
92 $entry->setPreviewPicture($content['open_graph']['og_image']); 92 $entry->setPreviewPicture($content['open_graph']['og_image']);
93 } 93 }
94 94
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
index 08f4676e..2cf596d4 100644
--- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
@@ -82,6 +82,6 @@ class SecurityControllerTest extends WallabagCoreTestCase
82 82
83 $client->followRedirects(); 83 $client->followRedirects();
84 $crawler = $client->request('GET', '/register'); 84 $crawler = $client->request('GET', '/register');
85 $this->assertContains('registration.submit', $crawler->filter('body')->extract(['_text'])[0]); 85 $this->assertContains('registration.submit', $client->getResponse()->getContent());
86 } 86 }
87} 87}
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 2ca13b91..5956b502 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -161,6 +161,47 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
161 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 161 $this->assertEquals('1.1.1.1', $entry->getDomainName());
162 } 162 }
163 163
164 public function testWithContentAndNoOgImage()
165 {
166 $tagger = $this->getTaggerMock();
167 $tagger->expects($this->once())
168 ->method('tag');
169
170 $graby = $this->getMockBuilder('Graby\Graby')
171 ->setMethods(['fetchContent'])
172 ->disableOriginalConstructor()
173 ->getMock();
174
175 $graby->expects($this->any())
176 ->method('fetchContent')
177 ->willReturn([
178 'html' => str_repeat('this is my content', 325),
179 'title' => 'this is my title',
180 'url' => 'http://1.1.1.1',
181 'content_type' => 'text/html',
182 'language' => 'fr',
183 'status' => '200',
184 'open_graph' => [
185 'og_title' => 'my OG title',
186 'og_description' => 'OG desc',
187 'og_image' => false,
188 ],
189 ]);
190
191 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
192 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
193
194 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
195 $this->assertEquals('this is my title', $entry->getTitle());
196 $this->assertContains('this is my content', $entry->getContent());
197 $this->assertNull($entry->getPreviewPicture());
198 $this->assertEquals('text/html', $entry->getMimetype());
199 $this->assertEquals('fr', $entry->getLanguage());
200 $this->assertEquals('200', $entry->getHttpStatus());
201 $this->assertEquals(4.0, $entry->getReadingTime());
202 $this->assertEquals('1.1.1.1', $entry->getDomainName());
203 }
204
164 public function testWithForcedContent() 205 public function testWithForcedContent()
165 { 206 {
166 $tagger = $this->getTaggerMock(); 207 $tagger = $this->getTaggerMock();