]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3293 from nclsHart/remove-unused-use
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Fri, 28 Jul 2017 05:35:48 +0000 (07:35 +0200)
committerGitHub <noreply@github.com>
Fri, 28 Jul 2017 05:35:48 +0000 (07:35 +0200)
Remove unused use statement in install command

.travis.yml
src/Wallabag/CoreBundle/Helper/ContentProxy.php
src/Wallabag/ImportBundle/Controller/BrowserController.php
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php

index 60e7dd1c834bd07478ea5b2a1a3da9cb929a2e78..6b279ed676c149a35d7fbe4b855ac6de67ff75a0 100644 (file)
@@ -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
index 656ac6eecb93b4430c2bf413787aaf680646a3c9..1ac7ad83c8ab753231ea72ec5c05db1205ae9aaf 100644 (file)
@@ -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]);
         }
index 0753e318b844175c8eb2b9f3de6490dbd8b56e07..77a7a9040621f2915517e6c2dd07527e9c0181cc 100644 (file)
@@ -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();
 }
index c76be13d52b8d2facfb1906b3a5712115bf3e7b2..2dc08be2e1174a51284e4d8f7593f6b24a4cdd56 100644 (file)
@@ -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']);
+    }
 }
index b1c6d53c5498b4945ddcbf5fbcd98d702f92223c..33bfa71e67d5c2e2f8a4abc03913a40e3b677fd6 100644 (file)
@@ -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',
             ],
         ];