diff --git a/composer.json b/composer.json
index 82fe61bd2..babe9356d 100644
--- a/composer.json
+++ b/composer.json
@@ -45,7 +45,7 @@
"nelmio/api-doc-bundle": "~2.7",
"ezyang/htmlpurifier": "~4.6",
"mgargano/simplehtmldom": "~1.5",
- "tecnick.com/tcpdf": "~6.2",
+ "tecnickcom/tcpdf": "~6.2",
"simplepie/simplepie": "~1.3.1",
"willdurand/hateoas-bundle": "~0.5.0",
"htmlawed/htmlawed": "~1.1.19",
diff --git a/composer.lock b/composer.lock
index ef060b5ec..370d8ddd9 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "d457fa385420eb29a177ac38eac977c3",
+ "hash": "350d05d95be50b6d93e8a046f784e00c",
"packages": [
{
"name": "doctrine/annotations",
@@ -1355,16 +1355,16 @@
},
{
"name": "j0k3r/php-readability",
- "version": "v1.0.7",
+ "version": "v1.0.8",
"source": {
"type": "git",
"url": "https://github.com/j0k3r/php-readability.git",
- "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4"
+ "reference": "f71c3a419623f821c245e0a003edfbf2c67f278e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/j0k3r/php-readability/zipball/1830dc45d4fccfe09d2d107ab59890f07adc35c4",
- "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4",
+ "url": "https://api.github.com/repos/j0k3r/php-readability/zipball/f71c3a419623f821c245e0a003edfbf2c67f278e",
+ "reference": "f71c3a419623f821c245e0a003edfbf2c67f278e",
"shasum": ""
},
"require": {
@@ -1414,7 +1414,7 @@
"extraction",
"html"
],
- "time": "2015-09-20 19:05:55"
+ "time": "2015-09-23 19:09:38"
},
{
"name": "jdorn/sql-formatter",
@@ -2970,20 +2970,20 @@
},
{
"name": "symfony/symfony",
- "version": "v2.7.4",
+ "version": "v2.7.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
- "reference": "1fdf23fe28876844b887b0e1935c9adda43ee645"
+ "reference": "619528a274647cffc1792063c3ea04c4fa8266a0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/symfony/zipball/1fdf23fe28876844b887b0e1935c9adda43ee645",
- "reference": "1fdf23fe28876844b887b0e1935c9adda43ee645",
+ "url": "https://api.github.com/repos/symfony/symfony/zipball/619528a274647cffc1792063c3ea04c4fa8266a0",
+ "reference": "619528a274647cffc1792063c3ea04c4fa8266a0",
"shasum": ""
},
"require": {
- "doctrine/common": "~2.3",
+ "doctrine/common": "~2.4",
"php": ">=5.3.9",
"psr/log": "~1.0",
"twig/twig": "~1.20|~2.0"
@@ -3036,9 +3036,9 @@
},
"require-dev": {
"doctrine/data-fixtures": "1.0.*",
- "doctrine/dbal": "~2.2",
+ "doctrine/dbal": "~2.4",
"doctrine/doctrine-bundle": "~1.2",
- "doctrine/orm": "~2.2,>=2.2.3",
+ "doctrine/orm": "~2.4,>=2.4.5",
"egulias/email-validator": "~1.2",
"ircmaxell/password-compat": "~1.0",
"monolog/monolog": "~1.11",
@@ -3088,70 +3088,7 @@
"keywords": [
"framework"
],
- "time": "2015-09-08 14:26:39"
- },
- {
- "name": "tecnick.com/tcpdf",
- "version": "6.2.11",
- "source": {
- "type": "git",
- "url": "https://github.com/tecnickcom/TCPDF.git",
- "reference": "354433a33946ae7497c3eab291eaaf814bccbfab"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/354433a33946ae7497c3eab291eaaf814bccbfab",
- "reference": "354433a33946ae7497c3eab291eaaf814bccbfab",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.0"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "fonts",
- "config",
- "include",
- "tcpdf.php",
- "tcpdf_parser.php",
- "tcpdf_import.php",
- "tcpdf_barcodes_1d.php",
- "tcpdf_barcodes_2d.php",
- "include/tcpdf_colors.php",
- "include/tcpdf_filters.php",
- "include/tcpdf_font_data.php",
- "include/tcpdf_fonts.php",
- "include/tcpdf_images.php",
- "include/tcpdf_static.php",
- "include/barcodes/datamatrix.php",
- "include/barcodes/pdf417.php",
- "include/barcodes/qrcode.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "LGPLv3"
- ],
- "authors": [
- {
- "name": "Nicola Asuni",
- "email": "info@tecnick.com",
- "homepage": "http://nicolaasuni.tecnick.com"
- }
- ],
- "description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
- "homepage": "http://www.tcpdf.org/",
- "keywords": [
- "PDFD32000-2008",
- "TCPDF",
- "barcodes",
- "datamatrix",
- "pdf",
- "pdf417",
- "qrcode"
- ],
- "time": "2015-08-02 12:30:27"
+ "time": "2015-09-25 11:16:52"
},
{
"name": "tecnickcom/tcpdf",
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
index dd316194c..7e64c5e1c 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
{
$entry1 = new Entry($this->getReference('admin-user'));
$entry1->setUrl('http://0.0.0.0');
+ $entry1->setReadingTime(11);
+ $entry1->setDomainName('domain.io');
$entry1->setTitle('test title entry1');
$entry1->setContent('This is my content /o/');
$entry1->setLanguage('en');
@@ -27,6 +29,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry2 = new Entry($this->getReference('admin-user'));
$entry2->setUrl('http://0.0.0.0');
+ $entry2->setReadingTime(1);
+ $entry2->setDomainName('domain.io');
$entry2->setTitle('test title entry2');
$entry2->setContent('This is my content /o/');
$entry2->setLanguage('fr');
@@ -37,6 +41,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry3 = new Entry($this->getReference('bob-user'));
$entry3->setUrl('http://0.0.0.0');
+ $entry3->setReadingTime(1);
+ $entry3->setDomainName('domain.io');
$entry3->setTitle('test title entry3');
$entry3->setContent('This is my content /o/');
$entry3->setLanguage('en');
@@ -55,6 +61,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry4 = new Entry($this->getReference('admin-user'));
$entry4->setUrl('http://0.0.0.0');
+ $entry4->setReadingTime(12);
+ $entry4->setDomainName('domain.io');
$entry4->setTitle('test title entry4');
$entry4->setContent('This is my content /o/');
$entry4->setLanguage('en');
@@ -73,10 +81,13 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry5 = new Entry($this->getReference('admin-user'));
$entry5->setUrl('http://0.0.0.0');
+ $entry5->setReadingTime(12);
+ $entry5->setDomainName('domain.io');
$entry5->setTitle('test title entry5');
$entry5->setContent('This is my content /o/');
$entry5->setStarred(true);
$entry5->setLanguage('fr');
+ $entry5->setPreviewPicture('http://0.0.0.0/image.jpg');
$manager->persist($entry5);
@@ -84,6 +95,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry6 = new Entry($this->getReference('admin-user'));
$entry6->setUrl('http://0.0.0.0');
+ $entry6->setReadingTime(12);
+ $entry6->setDomainName('domain.io');
$entry6->setTitle('test title entry6');
$entry6->setContent('This is my content /o/');
$entry6->setArchived(true);
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 7108889e0..9e81ba125 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;
use Symfony\Component\Validator\Constraints as Assert;
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation\XmlRoot;
-use Wallabag\CoreBundle\Tools\Utils;
/**
* Entry.
@@ -279,8 +278,6 @@ class Entry
public function setContent($content)
{
$this->content = $content;
- $this->readingTime = Utils::getReadingTime($content);
- $this->domainName = parse_url($this->url, PHP_URL_HOST);
return $this;
}
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 3de8828f9..7fb413931 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
use Graby\Graby;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Tools\Utils;
/**
* This kind of proxy class take care of getting the content from an url
@@ -51,6 +52,8 @@ class ContentProxy
$entry->setContent($html);
$entry->setLanguage($content['language']);
$entry->setMimetype($content['content_type']);
+ $entry->setReadingTime(Utils::getReadingTime($html));
+ $entry->setDomainName(parse_url($entry->getUrl(), PHP_URL_HOST));
if (isset($content['open_graph']['og_image'])) {
$entry->setPreviewPicture($content['open_graph']['og_image']);
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 87b9befeb..2286317c1 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -161,4 +161,22 @@ class EntryRepository extends EntityRepository
return $languages;
}
+
+ /**
+ * Used only in test case to get the right entry associated to the right user
+ *
+ * @param string $username
+ *
+ * @return Entry
+ */
+ public function findOneByUsernameAndNotArchived($username)
+ {
+ return $this->createQueryBuilder('e')
+ ->leftJoin('e.user', 'u')
+ ->where('u.username = :username')->setParameter('username', $username)
+ ->andWhere('e.isArchived = false')
+ ->setMaxResults(1)
+ ->getQuery()
+ ->getSingleResult();
+ }
}
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index cbd84a979..e9c85a172 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;
class EntryControllerTest extends WallabagCoreTestCase
{
+ 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';
+
public function testLogin()
{
$client = $this->getClient();
@@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[type=submit]')->form();
$data = array(
- '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',
+ 'entry[url]' => $this->url,
);
$client->submit($form, $data);
@@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsArchived(false);
+ ->findOneByUrl($this->url);
$client->request('GET', '/view/'.$content->getId());
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsArchived(false);
+ ->findOneByUrl($this->url);
$crawler = $client->request('GET', '/edit/'.$content->getId());
@@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsArchived(false);
+ ->findOneByUrl($this->url);
$crawler = $client->request('GET', '/edit/'.$content->getId());
@@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsArchived(false);
+ ->findOneByUrl($this->url);
$client->request('GET', '/archive/'.$content->getId());
@@ -174,7 +176,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneById($content->getId());
+ ->find($content->getId());
$this->assertEquals($res->isArchived(), true);
}
@@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsStarred(false);
+ ->findOneByUrl($this->url);
$client->request('GET', '/star/'.$content->getId());
@@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByIsStarred(false);
+ ->findOneByUrl($this->url);
$client->request('GET', '/delete/'.$content->getId());
@@ -222,21 +224,15 @@ class EntryControllerTest extends WallabagCoreTestCase
public function testViewOtherUserEntry()
{
- $this->logInAs('bob');
+ $this->logInAs('admin');
$client = $this->getClient();
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->createQueryBuilder('e')
- ->select('e.id')
- ->leftJoin('e.user', 'u')
- ->where('u.username != :username')->setParameter('username', 'bob')
- ->setMaxResults(1)
- ->getQuery()
- ->getSingleResult(AbstractQuery::HYDRATE_ARRAY);
+ ->findOneByUsernameAndNotArchived('bob');
- $client->request('GET', '/view/'.$content['id']);
+ $client->request('GET', '/view/'.$content->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
}
@@ -334,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
- 'entry_filter[domainName]' => 'monde',
+ 'entry_filter[domainName]' => 'domain',
);
$crawler = $client->submit($form, $data);
- $this->assertCount(1, $crawler->filter('div[class=entry]'));
+ $this->assertCount(5, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
@@ -360,14 +356,14 @@ class EntryControllerTest extends WallabagCoreTestCase
$form['entry_filter[isStarred]']->untick();
$crawler = $client->submit($form);
- $this->assertCount(2, $crawler->filter('div[class=entry]'));
+ $this->assertCount(1, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$form['entry_filter[isArchived]']->untick();
$form['entry_filter[isStarred]']->tick();
$crawler = $client->submit($form);
- $this->assertCount(2, $crawler->filter('div[class=entry]'));
+ $this->assertCount(1, $crawler->filter('div[class=entry]'));
}
public function testPreviewPictureFilter()
@@ -391,11 +387,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
- 'entry_filter[language]' => 'de',
+ 'entry_filter[language]' => 'fr',
);
$crawler = $client->submit($form, $data);
- $this->assertCount(1, $crawler->filter('div[class=entry]'));
+ $this->assertCount(2, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
index d25b2db5f..dc93dd6b8 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
$entry = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneBy(array());
+ ->findOneByUsernameAndNotArchived('admin');
$crawler = $client->request('GET', '/view/'.$entry->getId());
@@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
$newEntry = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneById($entry->getId());
+ ->find($entry->getId());
$this->assertEquals(1, count($newEntry->getTags()));
@@ -61,7 +61,7 @@ class TagControllerTest extends WallabagCoreTestCase
$newEntry = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneById($entry->getId());
+ ->find($entry->getId());
$this->assertEquals(2, count($newEntry->getTags()));
}
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
index 30065d6b7..0d3383894 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
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
+ $this->assertEquals(0.0, $entry->getReadingTime());
+ $this->assertEquals('0.0.0.0', $entry->getDomainName());
}
public function testWithEmptyContentButOG()
@@ -59,14 +61,16 @@ class ContentProxyTest extends KernelTestCase
));
$proxy = new ContentProxy($graby);
- $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
+ $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
- $this->assertEquals('http://0.0.0.0', $entry->getUrl());
+ $this->assertEquals('http://domain.io', $entry->getUrl());
$this->assertEquals('my title', $entry->getTitle());
$this->assertEquals('Unable to retrieve readable content.
But we found a short description:
desc', $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getLanguage());
$this->assertEmpty($entry->getMimetype());
+ $this->assertEquals(0.0, $entry->getReadingTime());
+ $this->assertEquals('domain.io', $entry->getDomainName());
}
public function testWithContent()
@@ -79,7 +83,7 @@ class ContentProxyTest extends KernelTestCase
$graby->expects($this->any())
->method('fetchContent')
->willReturn(array(
- 'html' => 'this is my content',
+ 'html' => str_repeat('this is my content', 325),
'title' => 'this is my title',
'url' => 'http://1.1.1.1',
'content_type' => 'text/html',
@@ -96,9 +100,11 @@ class ContentProxyTest extends KernelTestCase
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
- $this->assertEquals('this is my content', $entry->getContent());
+ $this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
+ $this->assertEquals(4.0, $entry->getReadingTime());
+ $this->assertEquals('1.1.1.1', $entry->getDomainName());
}
}