]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix tests 3258/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 3 Jul 2017 05:30:54 +0000 (07:30 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 3 Jul 2017 05:30:54 +0000 (07:30 +0200)
.travis.yml
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php

index e6cf96cb4ff2cb501e4838938b763a86650840a5..60e7dd1c834bd07478ea5b2a1a3da9cb929a2e78 100644 (file)
@@ -79,7 +79,7 @@ script:
     - echo "travis_fold:end:fixtures"
 
     - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then ./bin/simple-phpunit -v ; fi;
-    - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix src/ --verbose --dry-run ; fi;
+    - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix --verbose --dry-run ; fi;
     - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi;
     - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml app/Resources/CraueConfigBundle/translations -v ; fi;
     - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/UserBundle/Resources/translations -v ; fi;
index 445cfeebe627c3696cbf296a5686f392b5aa7cb4..845ebef680aef6df2f21096fa9785f28bedfd224 100644 (file)
@@ -195,7 +195,7 @@ class EntryController extends Controller
     public function showUnreadAction(Request $request, $page)
     {
         // load the quickstart if no entry in database
-        if ($page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
+        if ((int) $page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
             return $this->redirect($this->generateUrl('quickstart'));
         }
 
index a65bfe3b12d05435de01b860158324419589ae9f..c27ee90cc197c45ed9733db448b1d1f29f795741 100644 (file)
@@ -325,7 +325,7 @@ class EntryRepository extends EntityRepository
             ->where('e.user=:userId')->setParameter('userId', $userId)
         ;
 
-        return $qb->getQuery()->getSingleScalarResult();
+        return (int) $qb->getQuery()->getSingleScalarResult();
     }
 
     /**
@@ -345,7 +345,7 @@ class EntryRepository extends EntityRepository
             ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
         ;
 
-        return $qb->getQuery()->getSingleScalarResult();
+        return (int) $qb->getQuery()->getSingleScalarResult();
     }
 
     /**
index 2a333a0d15b89ca80e71f62572f6b01eea57ecaa..ae4af4cdf8cd31e4258c970b05017cab05788497 100644 (file)
@@ -405,8 +405,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $this->assertGreaterThan(0, $content['id']);
         $this->assertSame('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', $content['url']);
-        $this->assertSame(false, $content['is_archived']);
-        $this->assertSame(false, $content['is_starred']);
+        $this->assertSame(0, $content['is_archived']);
+        $this->assertSame(0, $content['is_starred']);
         $this->assertSame('New title for my article', $content['title']);
         $this->assertSame(1, $content['user_id']);
         $this->assertCount(2, $content['tags']);
@@ -433,8 +433,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $this->assertGreaterThan(0, $content['id']);
         $this->assertSame('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', $content['url']);
-        $this->assertSame(true, $content['is_archived']);
-        $this->assertSame(false, $content['is_starred']);
+        $this->assertSame(1, $content['is_archived']);
+        $this->assertSame(0, $content['is_starred']);
         $this->assertCount(3, $content['tags']);
     }
 
@@ -485,8 +485,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $this->assertGreaterThan(0, $content['id']);
         $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
-        $this->assertSame(true, $content['is_archived']);
-        $this->assertSame(true, $content['is_starred']);
+        $this->assertSame(1, $content['is_archived']);
+        $this->assertSame(1, $content['is_starred']);
         $this->assertSame(1, $content['user_id']);
     }
 
@@ -504,8 +504,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $this->assertGreaterThan(0, $content['id']);
         $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
-        $this->assertSame(false, $content['is_archived']);
-        $this->assertSame(true, $content['is_starred']);
+        $this->assertSame(0, $content['is_archived']);
+        $this->assertSame(1, $content['is_starred']);
     }
 
     public function testPatchEntry()
@@ -691,7 +691,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
-        $this->assertSame(true, $content['is_archived']);
+        $this->assertSame(1, $content['is_archived']);
     }
 
     public function testSaveIsStarredAfterPost()
@@ -713,7 +713,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
-        $this->assertSame(true, $content['is_starred']);
+        $this->assertSame(1, $content['is_starred']);
     }
 
     public function testSaveIsArchivedAfterPatch()
@@ -735,7 +735,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
-        $this->assertSame(true, $content['is_archived']);
+        $this->assertSame(1, $content['is_archived']);
     }
 
     public function testSaveIsStarredAfterPatch()
@@ -756,7 +756,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
-        $this->assertSame(true, $content['is_starred']);
+        $this->assertSame(1, $content['is_starred']);
     }
 
     public function dataForEntriesExistWithUrl()
index b528bcdb6f7da9a78b8e9c34afd2666ab34e62f3..b1c6d53c5498b4945ddcbf5fbcd98d702f92223c 100644 (file)
@@ -43,6 +43,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $client = $this->getClient();
 
         $client->request('GET', '/unread/list');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
         $crawler = $client->followRedirect();
 
         $this->assertSame(200, $client->getResponse()->getStatusCode());
@@ -505,7 +506,7 @@ class EntryControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->find($entry->getId());
 
-        $this->assertSame($res->isArchived(), true);
+        $this->assertSame(1, $res->isArchived());
     }
 
     public function testToggleStar()
@@ -528,7 +529,7 @@ class EntryControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->findOneById($entry->getId());
 
-        $this->assertSame($res->isStarred(), true);
+        $this->assertSame(1, $res->isStarred());
     }
 
     public function testDelete()
@@ -1004,7 +1005,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertSame($url, $entry->getUrl());
         $this->assertContains('Perpignan', $entry->getTitle());
         // instead of checking for the filename (which might change) check that the image is now local
-        $this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent());
+        $this->assertContains($client->getContainer()->getParameter('domain_name') . '/assets/images/', $entry->getContent());
 
         $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
     }
@@ -1296,7 +1297,7 @@ class EntryControllerTest extends WallabagCoreTestCase
             ],
             'fucked_list_of_languages' => [
                 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home',
-                '',
+                null,
             ],
             'es-ES' => [
                 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google',
index ba9296af1c6300b36ea2cbcfc4cc1df43ddceea4..3e216381eb797903c2b7b38dfcafe33327201d66 100644 (file)
@@ -230,8 +230,8 @@ class ExportControllerTest extends WallabagCoreTestCase
         $this->assertArrayHasKey('created_at', $content[0]);
         $this->assertArrayHasKey('updated_at', $content[0]);
 
-        $this->assertSame($contentInDB->isArchived(), $content[0]['is_archived']);
-        $this->assertSame($contentInDB->isStarred(), $content[0]['is_starred']);
+        $this->assertSame((int) $contentInDB->isArchived(), $content[0]['is_archived']);
+        $this->assertSame((int) $contentInDB->isStarred(), $content[0]['is_starred']);
         $this->assertSame($contentInDB->getTitle(), $content[0]['title']);
         $this->assertSame($contentInDB->getUrl(), $content[0]['url']);
         $this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
index 91ce0102255ab93d15852eef252f77c69633005c..5ffe1ca6d85468e6f3dd9c90e036ae488912ff54 100644 (file)
@@ -53,6 +53,6 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
 
         $listener->onInteractiveLogin($event);
 
-        $this->assertSame('', $session->get('_locale'));
+        $this->assertNull($session->get('_locale'));
     }
 }
index 85036e35160c9b25e593068fa76c733e87dd34f5..5d6a29fec9fcd9ec3efef558c8c51e87adb9d89d 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
 
-use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
 use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
 use Monolog\Handler\TestHandler;
 use Monolog\Logger;
@@ -68,20 +67,15 @@ class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
 
         $config = $this->builder->buildForHost('www.example.com');
 
-        $this->assertSame(
-            new SiteConfig([
-                'host' => 'example.com',
-                'requiresLogin' => true,
-                'loginUri' => 'http://www.example.com/login',
-                'usernameField' => 'login',
-                'passwordField' => 'password',
-                'extraFields' => ['field' => 'value'],
-                'notLoggedInXpath' => '//div[@class="need-login"]',
-                'username' => 'foo',
-                'password' => 'bar',
-            ]),
-            $config
-        );
+        $this->assertSame('example.com', $config->getHost());
+        $this->assertSame(true, $config->requiresLogin());
+        $this->assertSame('http://www.example.com/login', $config->getLoginUri());
+        $this->assertSame('login', $config->getUsernameField());
+        $this->assertSame('password', $config->getPasswordField());
+        $this->assertSame(['field' => 'value'], $config->getExtraFields());
+        $this->assertSame('//div[@class="need-login"]', $config->getNotLoggedInXpath());
+        $this->assertSame('foo', $config->getUsername());
+        $this->assertSame('bar', $config->getPassword());
 
         $records = $handler->getRecords();
 
index 7e19631bf0314a798c8fd85a1f204ececbeb8a24..c63671c4613e4e536f84f9da3752f00911ee5ecf 100644 (file)
@@ -51,7 +51,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
         $this->assertEmpty($entry->getMimetype());
         $this->assertEmpty($entry->getLanguage());
         $this->assertSame(0.0, $entry->getReadingTime());
-        $this->assertSame(false, $entry->getDomainName());
+        $this->assertSame(null, $entry->getDomainName());
     }
 
     public function testWithEmptyContent()