diff options
Diffstat (limited to 'src')
7 files changed, 66 insertions, 33 deletions
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index dd316194..7e64c5e1 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php | |||
@@ -17,6 +17,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
17 | { | 17 | { |
18 | $entry1 = new Entry($this->getReference('admin-user')); | 18 | $entry1 = new Entry($this->getReference('admin-user')); |
19 | $entry1->setUrl('http://0.0.0.0'); | 19 | $entry1->setUrl('http://0.0.0.0'); |
20 | $entry1->setReadingTime(11); | ||
21 | $entry1->setDomainName('domain.io'); | ||
20 | $entry1->setTitle('test title entry1'); | 22 | $entry1->setTitle('test title entry1'); |
21 | $entry1->setContent('This is my content /o/'); | 23 | $entry1->setContent('This is my content /o/'); |
22 | $entry1->setLanguage('en'); | 24 | $entry1->setLanguage('en'); |
@@ -27,6 +29,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
27 | 29 | ||
28 | $entry2 = new Entry($this->getReference('admin-user')); | 30 | $entry2 = new Entry($this->getReference('admin-user')); |
29 | $entry2->setUrl('http://0.0.0.0'); | 31 | $entry2->setUrl('http://0.0.0.0'); |
32 | $entry2->setReadingTime(1); | ||
33 | $entry2->setDomainName('domain.io'); | ||
30 | $entry2->setTitle('test title entry2'); | 34 | $entry2->setTitle('test title entry2'); |
31 | $entry2->setContent('This is my content /o/'); | 35 | $entry2->setContent('This is my content /o/'); |
32 | $entry2->setLanguage('fr'); | 36 | $entry2->setLanguage('fr'); |
@@ -37,6 +41,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
37 | 41 | ||
38 | $entry3 = new Entry($this->getReference('bob-user')); | 42 | $entry3 = new Entry($this->getReference('bob-user')); |
39 | $entry3->setUrl('http://0.0.0.0'); | 43 | $entry3->setUrl('http://0.0.0.0'); |
44 | $entry3->setReadingTime(1); | ||
45 | $entry3->setDomainName('domain.io'); | ||
40 | $entry3->setTitle('test title entry3'); | 46 | $entry3->setTitle('test title entry3'); |
41 | $entry3->setContent('This is my content /o/'); | 47 | $entry3->setContent('This is my content /o/'); |
42 | $entry3->setLanguage('en'); | 48 | $entry3->setLanguage('en'); |
@@ -55,6 +61,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
55 | 61 | ||
56 | $entry4 = new Entry($this->getReference('admin-user')); | 62 | $entry4 = new Entry($this->getReference('admin-user')); |
57 | $entry4->setUrl('http://0.0.0.0'); | 63 | $entry4->setUrl('http://0.0.0.0'); |
64 | $entry4->setReadingTime(12); | ||
65 | $entry4->setDomainName('domain.io'); | ||
58 | $entry4->setTitle('test title entry4'); | 66 | $entry4->setTitle('test title entry4'); |
59 | $entry4->setContent('This is my content /o/'); | 67 | $entry4->setContent('This is my content /o/'); |
60 | $entry4->setLanguage('en'); | 68 | $entry4->setLanguage('en'); |
@@ -73,10 +81,13 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
73 | 81 | ||
74 | $entry5 = new Entry($this->getReference('admin-user')); | 82 | $entry5 = new Entry($this->getReference('admin-user')); |
75 | $entry5->setUrl('http://0.0.0.0'); | 83 | $entry5->setUrl('http://0.0.0.0'); |
84 | $entry5->setReadingTime(12); | ||
85 | $entry5->setDomainName('domain.io'); | ||
76 | $entry5->setTitle('test title entry5'); | 86 | $entry5->setTitle('test title entry5'); |
77 | $entry5->setContent('This is my content /o/'); | 87 | $entry5->setContent('This is my content /o/'); |
78 | $entry5->setStarred(true); | 88 | $entry5->setStarred(true); |
79 | $entry5->setLanguage('fr'); | 89 | $entry5->setLanguage('fr'); |
90 | $entry5->setPreviewPicture('http://0.0.0.0/image.jpg'); | ||
80 | 91 | ||
81 | $manager->persist($entry5); | 92 | $manager->persist($entry5); |
82 | 93 | ||
@@ -84,6 +95,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
84 | 95 | ||
85 | $entry6 = new Entry($this->getReference('admin-user')); | 96 | $entry6 = new Entry($this->getReference('admin-user')); |
86 | $entry6->setUrl('http://0.0.0.0'); | 97 | $entry6->setUrl('http://0.0.0.0'); |
98 | $entry6->setReadingTime(12); | ||
99 | $entry6->setDomainName('domain.io'); | ||
87 | $entry6->setTitle('test title entry6'); | 100 | $entry6->setTitle('test title entry6'); |
88 | $entry6->setContent('This is my content /o/'); | 101 | $entry6->setContent('This is my content /o/'); |
89 | $entry6->setArchived(true); | 102 | $entry6->setArchived(true); |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 7108889e..9e81ba12 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM; | |||
7 | use Symfony\Component\Validator\Constraints as Assert; | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | use Hateoas\Configuration\Annotation as Hateoas; | 8 | use Hateoas\Configuration\Annotation as Hateoas; |
9 | use JMS\Serializer\Annotation\XmlRoot; | 9 | use JMS\Serializer\Annotation\XmlRoot; |
10 | use Wallabag\CoreBundle\Tools\Utils; | ||
11 | 10 | ||
12 | /** | 11 | /** |
13 | * Entry. | 12 | * Entry. |
@@ -279,8 +278,6 @@ class Entry | |||
279 | public function setContent($content) | 278 | public function setContent($content) |
280 | { | 279 | { |
281 | $this->content = $content; | 280 | $this->content = $content; |
282 | $this->readingTime = Utils::getReadingTime($content); | ||
283 | $this->domainName = parse_url($this->url, PHP_URL_HOST); | ||
284 | 281 | ||
285 | return $this; | 282 | return $this; |
286 | } | 283 | } |
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 3de8828f..7fb41393 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Helper; | |||
4 | 4 | ||
5 | use Graby\Graby; | 5 | use Graby\Graby; |
6 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
7 | use Wallabag\CoreBundle\Tools\Utils; | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * This kind of proxy class take care of getting the content from an url | 10 | * This kind of proxy class take care of getting the content from an url |
@@ -51,6 +52,8 @@ class ContentProxy | |||
51 | $entry->setContent($html); | 52 | $entry->setContent($html); |
52 | $entry->setLanguage($content['language']); | 53 | $entry->setLanguage($content['language']); |
53 | $entry->setMimetype($content['content_type']); | 54 | $entry->setMimetype($content['content_type']); |
55 | $entry->setReadingTime(Utils::getReadingTime($html)); | ||
56 | $entry->setDomainName(parse_url($entry->getUrl(), PHP_URL_HOST)); | ||
54 | 57 | ||
55 | if (isset($content['open_graph']['og_image'])) { | 58 | if (isset($content['open_graph']['og_image'])) { |
56 | $entry->setPreviewPicture($content['open_graph']['og_image']); | 59 | $entry->setPreviewPicture($content['open_graph']['og_image']); |
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 87b9befe..2286317c 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -161,4 +161,22 @@ class EntryRepository extends EntityRepository | |||
161 | 161 | ||
162 | return $languages; | 162 | return $languages; |
163 | } | 163 | } |
164 | |||
165 | /** | ||
166 | * Used only in test case to get the right entry associated to the right user | ||
167 | * | ||
168 | * @param string $username | ||
169 | * | ||
170 | * @return Entry | ||
171 | */ | ||
172 | public function findOneByUsernameAndNotArchived($username) | ||
173 | { | ||
174 | return $this->createQueryBuilder('e') | ||
175 | ->leftJoin('e.user', 'u') | ||
176 | ->where('u.username = :username')->setParameter('username', $username) | ||
177 | ->andWhere('e.isArchived = false') | ||
178 | ->setMaxResults(1) | ||
179 | ->getQuery() | ||
180 | ->getSingleResult(); | ||
181 | } | ||
164 | } | 182 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index cbd84a97..e9c85a17 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -7,6 +7,8 @@ use Doctrine\ORM\AbstractQuery; | |||
7 | 7 | ||
8 | class EntryControllerTest extends WallabagCoreTestCase | 8 | class EntryControllerTest extends WallabagCoreTestCase |
9 | { | 9 | { |
10 | public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; | ||
11 | |||
10 | public function testLogin() | 12 | public function testLogin() |
11 | { | 13 | { |
12 | $client = $this->getClient(); | 14 | $client = $this->getClient(); |
@@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
60 | $form = $crawler->filter('button[type=submit]')->form(); | 62 | $form = $crawler->filter('button[type=submit]')->form(); |
61 | 63 | ||
62 | $data = array( | 64 | $data = array( |
63 | 'entry[url]' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', | 65 | 'entry[url]' => $this->url, |
64 | ); | 66 | ); |
65 | 67 | ||
66 | $client->submit($form, $data); | 68 | $client->submit($form, $data); |
@@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
101 | $content = $client->getContainer() | 103 | $content = $client->getContainer() |
102 | ->get('doctrine.orm.entity_manager') | 104 | ->get('doctrine.orm.entity_manager') |
103 | ->getRepository('WallabagCoreBundle:Entry') | 105 | ->getRepository('WallabagCoreBundle:Entry') |
104 | ->findOneByIsArchived(false); | 106 | ->findOneByUrl($this->url); |
105 | 107 | ||
106 | $client->request('GET', '/view/'.$content->getId()); | 108 | $client->request('GET', '/view/'.$content->getId()); |
107 | 109 | ||
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
117 | $content = $client->getContainer() | 119 | $content = $client->getContainer() |
118 | ->get('doctrine.orm.entity_manager') | 120 | ->get('doctrine.orm.entity_manager') |
119 | ->getRepository('WallabagCoreBundle:Entry') | 121 | ->getRepository('WallabagCoreBundle:Entry') |
120 | ->findOneByIsArchived(false); | 122 | ->findOneByUrl($this->url); |
121 | 123 | ||
122 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | 124 | $crawler = $client->request('GET', '/edit/'.$content->getId()); |
123 | 125 | ||
@@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
135 | $content = $client->getContainer() | 137 | $content = $client->getContainer() |
136 | ->get('doctrine.orm.entity_manager') | 138 | ->get('doctrine.orm.entity_manager') |
137 | ->getRepository('WallabagCoreBundle:Entry') | 139 | ->getRepository('WallabagCoreBundle:Entry') |
138 | ->findOneByIsArchived(false); | 140 | ->findOneByUrl($this->url); |
139 | 141 | ||
140 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | 142 | $crawler = $client->request('GET', '/edit/'.$content->getId()); |
141 | 143 | ||
@@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
165 | $content = $client->getContainer() | 167 | $content = $client->getContainer() |
166 | ->get('doctrine.orm.entity_manager') | 168 | ->get('doctrine.orm.entity_manager') |
167 | ->getRepository('WallabagCoreBundle:Entry') | 169 | ->getRepository('WallabagCoreBundle:Entry') |
168 | ->findOneByIsArchived(false); | 170 | ->findOneByUrl($this->url); |
169 | 171 | ||
170 | $client->request('GET', '/archive/'.$content->getId()); | 172 | $client->request('GET', '/archive/'.$content->getId()); |
171 | 173 | ||
@@ -174,7 +176,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
174 | $res = $client->getContainer() | 176 | $res = $client->getContainer() |
175 | ->get('doctrine.orm.entity_manager') | 177 | ->get('doctrine.orm.entity_manager') |
176 | ->getRepository('WallabagCoreBundle:Entry') | 178 | ->getRepository('WallabagCoreBundle:Entry') |
177 | ->findOneById($content->getId()); | 179 | ->find($content->getId()); |
178 | 180 | ||
179 | $this->assertEquals($res->isArchived(), true); | 181 | $this->assertEquals($res->isArchived(), true); |
180 | } | 182 | } |
@@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
187 | $content = $client->getContainer() | 189 | $content = $client->getContainer() |
188 | ->get('doctrine.orm.entity_manager') | 190 | ->get('doctrine.orm.entity_manager') |
189 | ->getRepository('WallabagCoreBundle:Entry') | 191 | ->getRepository('WallabagCoreBundle:Entry') |
190 | ->findOneByIsStarred(false); | 192 | ->findOneByUrl($this->url); |
191 | 193 | ||
192 | $client->request('GET', '/star/'.$content->getId()); | 194 | $client->request('GET', '/star/'.$content->getId()); |
193 | 195 | ||
@@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
209 | $content = $client->getContainer() | 211 | $content = $client->getContainer() |
210 | ->get('doctrine.orm.entity_manager') | 212 | ->get('doctrine.orm.entity_manager') |
211 | ->getRepository('WallabagCoreBundle:Entry') | 213 | ->getRepository('WallabagCoreBundle:Entry') |
212 | ->findOneByIsStarred(false); | 214 | ->findOneByUrl($this->url); |
213 | 215 | ||
214 | $client->request('GET', '/delete/'.$content->getId()); | 216 | $client->request('GET', '/delete/'.$content->getId()); |
215 | 217 | ||
@@ -222,21 +224,15 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
222 | 224 | ||
223 | public function testViewOtherUserEntry() | 225 | public function testViewOtherUserEntry() |
224 | { | 226 | { |
225 | $this->logInAs('bob'); | 227 | $this->logInAs('admin'); |
226 | $client = $this->getClient(); | 228 | $client = $this->getClient(); |
227 | 229 | ||
228 | $content = $client->getContainer() | 230 | $content = $client->getContainer() |
229 | ->get('doctrine.orm.entity_manager') | 231 | ->get('doctrine.orm.entity_manager') |
230 | ->getRepository('WallabagCoreBundle:Entry') | 232 | ->getRepository('WallabagCoreBundle:Entry') |
231 | ->createQueryBuilder('e') | 233 | ->findOneByUsernameAndNotArchived('bob'); |
232 | ->select('e.id') | ||
233 | ->leftJoin('e.user', 'u') | ||
234 | ->where('u.username != :username')->setParameter('username', 'bob') | ||
235 | ->setMaxResults(1) | ||
236 | ->getQuery() | ||
237 | ->getSingleResult(AbstractQuery::HYDRATE_ARRAY); | ||
238 | 234 | ||
239 | $client->request('GET', '/view/'.$content['id']); | 235 | $client->request('GET', '/view/'.$content->getId()); |
240 | 236 | ||
241 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | 237 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); |
242 | } | 238 | } |
@@ -334,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
334 | $crawler = $client->request('GET', '/unread/list'); | 330 | $crawler = $client->request('GET', '/unread/list'); |
335 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 331 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
336 | $data = array( | 332 | $data = array( |
337 | 'entry_filter[domainName]' => 'monde', | 333 | 'entry_filter[domainName]' => 'domain', |
338 | ); | 334 | ); |
339 | 335 | ||
340 | $crawler = $client->submit($form, $data); | 336 | $crawler = $client->submit($form, $data); |
341 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 337 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
342 | 338 | ||
343 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 339 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
344 | $data = array( | 340 | $data = array( |
@@ -360,14 +356,14 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
360 | $form['entry_filter[isStarred]']->untick(); | 356 | $form['entry_filter[isStarred]']->untick(); |
361 | 357 | ||
362 | $crawler = $client->submit($form); | 358 | $crawler = $client->submit($form); |
363 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 359 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
364 | 360 | ||
365 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 361 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
366 | $form['entry_filter[isArchived]']->untick(); | 362 | $form['entry_filter[isArchived]']->untick(); |
367 | $form['entry_filter[isStarred]']->tick(); | 363 | $form['entry_filter[isStarred]']->tick(); |
368 | 364 | ||
369 | $crawler = $client->submit($form); | 365 | $crawler = $client->submit($form); |
370 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 366 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
371 | } | 367 | } |
372 | 368 | ||
373 | public function testPreviewPictureFilter() | 369 | public function testPreviewPictureFilter() |
@@ -391,11 +387,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
391 | $crawler = $client->request('GET', '/unread/list'); | 387 | $crawler = $client->request('GET', '/unread/list'); |
392 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 388 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
393 | $data = array( | 389 | $data = array( |
394 | 'entry_filter[language]' => 'de', | 390 | 'entry_filter[language]' => 'fr', |
395 | ); | 391 | ); |
396 | 392 | ||
397 | $crawler = $client->submit($form, $data); | 393 | $crawler = $client->submit($form, $data); |
398 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 394 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
399 | 395 | ||
400 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 396 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
401 | $data = array( | 397 | $data = array( |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index d25b2db5..dc93dd6b 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php | |||
@@ -24,7 +24,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
24 | $entry = $client->getContainer() | 24 | $entry = $client->getContainer() |
25 | ->get('doctrine.orm.entity_manager') | 25 | ->get('doctrine.orm.entity_manager') |
26 | ->getRepository('WallabagCoreBundle:Entry') | 26 | ->getRepository('WallabagCoreBundle:Entry') |
27 | ->findOneBy(array()); | 27 | ->findOneByUsernameAndNotArchived('admin'); |
28 | 28 | ||
29 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 29 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
30 | 30 | ||
@@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
46 | $newEntry = $client->getContainer() | 46 | $newEntry = $client->getContainer() |
47 | ->get('doctrine.orm.entity_manager') | 47 | ->get('doctrine.orm.entity_manager') |
48 | ->getRepository('WallabagCoreBundle:Entry') | 48 | ->getRepository('WallabagCoreBundle:Entry') |
49 | ->findOneById($entry->getId()); | 49 | ->find($entry->getId()); |
50 | 50 | ||
51 | $this->assertEquals(1, count($newEntry->getTags())); | 51 | $this->assertEquals(1, count($newEntry->getTags())); |
52 | 52 | ||
@@ -61,7 +61,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
61 | $newEntry = $client->getContainer() | 61 | $newEntry = $client->getContainer() |
62 | ->get('doctrine.orm.entity_manager') | 62 | ->get('doctrine.orm.entity_manager') |
63 | ->getRepository('WallabagCoreBundle:Entry') | 63 | ->getRepository('WallabagCoreBundle:Entry') |
64 | ->findOneById($entry->getId()); | 64 | ->find($entry->getId()); |
65 | 65 | ||
66 | $this->assertEquals(2, count($newEntry->getTags())); | 66 | $this->assertEquals(2, count($newEntry->getTags())); |
67 | } | 67 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php index 30065d6b..0d338389 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php | |||
@@ -35,6 +35,8 @@ class ContentProxyTest extends KernelTestCase | |||
35 | $this->assertEmpty($entry->getPreviewPicture()); | 35 | $this->assertEmpty($entry->getPreviewPicture()); |
36 | $this->assertEmpty($entry->getMimetype()); | 36 | $this->assertEmpty($entry->getMimetype()); |
37 | $this->assertEmpty($entry->getLanguage()); | 37 | $this->assertEmpty($entry->getLanguage()); |
38 | $this->assertEquals(0.0, $entry->getReadingTime()); | ||
39 | $this->assertEquals('0.0.0.0', $entry->getDomainName()); | ||
38 | } | 40 | } |
39 | 41 | ||
40 | public function testWithEmptyContentButOG() | 42 | public function testWithEmptyContentButOG() |
@@ -59,14 +61,16 @@ class ContentProxyTest extends KernelTestCase | |||
59 | )); | 61 | )); |
60 | 62 | ||
61 | $proxy = new ContentProxy($graby); | 63 | $proxy = new ContentProxy($graby); |
62 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 64 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); |
63 | 65 | ||
64 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); | 66 | $this->assertEquals('http://domain.io', $entry->getUrl()); |
65 | $this->assertEquals('my title', $entry->getTitle()); | 67 | $this->assertEquals('my title', $entry->getTitle()); |
66 | $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); | 68 | $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
67 | $this->assertEmpty($entry->getPreviewPicture()); | 69 | $this->assertEmpty($entry->getPreviewPicture()); |
68 | $this->assertEmpty($entry->getLanguage()); | 70 | $this->assertEmpty($entry->getLanguage()); |
69 | $this->assertEmpty($entry->getMimetype()); | 71 | $this->assertEmpty($entry->getMimetype()); |
72 | $this->assertEquals(0.0, $entry->getReadingTime()); | ||
73 | $this->assertEquals('domain.io', $entry->getDomainName()); | ||
70 | } | 74 | } |
71 | 75 | ||
72 | public function testWithContent() | 76 | public function testWithContent() |
@@ -79,7 +83,7 @@ class ContentProxyTest extends KernelTestCase | |||
79 | $graby->expects($this->any()) | 83 | $graby->expects($this->any()) |
80 | ->method('fetchContent') | 84 | ->method('fetchContent') |
81 | ->willReturn(array( | 85 | ->willReturn(array( |
82 | 'html' => 'this is my content', | 86 | 'html' => str_repeat('this is my content', 325), |
83 | 'title' => 'this is my title', | 87 | 'title' => 'this is my title', |
84 | 'url' => 'http://1.1.1.1', | 88 | 'url' => 'http://1.1.1.1', |
85 | 'content_type' => 'text/html', | 89 | 'content_type' => 'text/html', |
@@ -96,9 +100,11 @@ class ContentProxyTest extends KernelTestCase | |||
96 | 100 | ||
97 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 101 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); |
98 | $this->assertEquals('this is my title', $entry->getTitle()); | 102 | $this->assertEquals('this is my title', $entry->getTitle()); |
99 | $this->assertEquals('this is my content', $entry->getContent()); | 103 | $this->assertContains('this is my content', $entry->getContent()); |
100 | $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); | 104 | $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); |
101 | $this->assertEquals('text/html', $entry->getMimetype()); | 105 | $this->assertEquals('text/html', $entry->getMimetype()); |
102 | $this->assertEquals('fr', $entry->getLanguage()); | 106 | $this->assertEquals('fr', $entry->getLanguage()); |
107 | $this->assertEquals(4.0, $entry->getReadingTime()); | ||
108 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | ||
103 | } | 109 | } |
104 | } | 110 | } |