From: Jérémy Benoist Date: Fri, 28 Jul 2017 05:38:15 +0000 (+0200) Subject: Merge pull request #3291 from nclsHart/show-user-io X-Git-Tag: 2.3.0~31^2~33 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=233eb91be4bd381ff48de0a15aff94415a3f2797;hp=d58199f3624c1cca1f851b4af5b8c88dea613a3b;p=github%2Fwallabag%2Fwallabag.git Merge pull request #3291 from nclsHart/show-user-io Better rendering for show user command using symfony style --- diff --git a/.travis.yml b/.travis.yml index 60e7dd1c..6b279ed6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - nightly node_js: @@ -43,6 +44,7 @@ matrix: - php: 7.0 env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite allow_failures: + - php: 7.2 - php: nightly # exclude v1 branches diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php index d964439d..b4aa4e47 100644 --- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php +++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php @@ -111,9 +111,4 @@ class CleanDuplicatesCommand extends ContainerAwareCommand { return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); - } } diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php index c2e4be05..291926e4 100644 --- a/src/Wallabag/CoreBundle/Command/ExportCommand.php +++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php @@ -69,9 +69,4 @@ class ExportCommand extends ContainerAwareCommand return 0; } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); - } } diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 50551480..c7809053 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -14,7 +14,6 @@ use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; -use Wallabag\CoreBundle\Entity\Config; class InstallCommand extends ContainerAwareCommand { diff --git a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php index 33888fa3..090309d9 100644 --- a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php +++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php @@ -72,9 +72,4 @@ class ShowUserCommand extends ContainerAwareCommand { return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); - } } diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 656ac6ee..1ac7ad83 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -126,11 +126,17 @@ class ContentProxy // is it a timestamp? if (filter_var($date, FILTER_VALIDATE_INT) !== false) { - $date = '@' . $value; + $date = '@' . $date; } try { - $entry->setPublishedAt(new \DateTime($date)); + // is it already a DateTime? + // (it's inside the try/catch in case of fail to be parse time string) + if (!$date instanceof \DateTime) { + $date = new \DateTime($date); + } + + $entry->setPublishedAt($date); } catch (\Exception $e) { $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $entry->getUrl(), 'date' => $value]); } diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php index 0753e318..77a7a904 100644 --- a/src/Wallabag/ImportBundle/Controller/BrowserController.php +++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php @@ -80,10 +80,10 @@ abstract class BrowserController extends Controller */ abstract protected function getImportService(); - /** - * Return the template used for the form. - * - * @return string - */ - abstract protected function getImportTemplate(); + /** + * Return the template used for the form. + * + * @return string + */ + abstract protected function getImportTemplate(); } diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index c76be13d..2dc08be2 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -421,6 +421,16 @@ class EntryRestControllerTest extends WallabagApiTestCase public function testPostSameEntry() { + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + $entry = new Entry($em->getReference(User::class, 1)); + $entry->setUrl('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->setArchived(true); + $entry->addTag((new Tag())->setLabel('google')); + $entry->addTag((new Tag())->setLabel('apple')); + $em->persist($entry); + $em->flush(); + $em->clear(); + $this->client->request('POST', '/api/entries.json', [ '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', 'archive' => '1', @@ -1046,4 +1056,28 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertSame(400, $this->client->getResponse()->getStatusCode()); $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); } + + public function testRePostEntryAndReUsePublishedAt() + { + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + $entry = new Entry($em->getReference(User::class, 1)); + $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »'); + $entry->setContent('hihi'); + $entry->setUrl('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html'); + $entry->setPublishedAt(new \DateTime('2017-06-26T07:46:02+0200')); + $em->persist($entry); + $em->flush(); + $em->clear(); + + $this->client->request('POST', '/api/entries.json', [ + 'url' => 'http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', + ]); + + $this->assertSame(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertGreaterThan(0, $content['id']); + $this->assertSame('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', $content['url']); + } } diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index b1c6d53c..33bfa71e 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1300,7 +1300,7 @@ class EntryControllerTest extends WallabagCoreTestCase null, ], 'es-ES' => [ - 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google', + 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/', 'es_ES', ], ];