Fix tests

This commit is contained in:
Jeremy Benoist 2017-07-03 07:30:54 +02:00
parent f808b01692
commit 38520658ad
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
9 changed files with 34 additions and 39 deletions

View file

@ -79,7 +79,7 @@ script:
- echo "travis_fold:end:fixtures" - echo "travis_fold:end:fixtures"
- if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then ./bin/simple-phpunit -v ; fi; - 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 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 app/Resources/CraueConfigBundle/translations -v ; fi;
- if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/UserBundle/Resources/translations -v ; fi; - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/UserBundle/Resources/translations -v ; fi;

View file

@ -195,7 +195,7 @@ class EntryController extends Controller
public function showUnreadAction(Request $request, $page) public function showUnreadAction(Request $request, $page)
{ {
// load the quickstart if no entry in database // 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')); return $this->redirect($this->generateUrl('quickstart'));
} }

View file

@ -325,7 +325,7 @@ class EntryRepository extends EntityRepository
->where('e.user=:userId')->setParameter('userId', $userId) ->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) ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
; ;
return $qb->getQuery()->getSingleScalarResult(); return (int) $qb->getQuery()->getSingleScalarResult();
} }
/** /**

View file

@ -405,8 +405,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertGreaterThan(0, $content['id']); $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('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(0, $content['is_archived']);
$this->assertSame(false, $content['is_starred']); $this->assertSame(0, $content['is_starred']);
$this->assertSame('New title for my article', $content['title']); $this->assertSame('New title for my article', $content['title']);
$this->assertSame(1, $content['user_id']); $this->assertSame(1, $content['user_id']);
$this->assertCount(2, $content['tags']); $this->assertCount(2, $content['tags']);
@ -433,8 +433,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertGreaterThan(0, $content['id']); $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('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(1, $content['is_archived']);
$this->assertSame(false, $content['is_starred']); $this->assertSame(0, $content['is_starred']);
$this->assertCount(3, $content['tags']); $this->assertCount(3, $content['tags']);
} }
@ -485,8 +485,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertGreaterThan(0, $content['id']); $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('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(1, $content['is_archived']);
$this->assertSame(true, $content['is_starred']); $this->assertSame(1, $content['is_starred']);
$this->assertSame(1, $content['user_id']); $this->assertSame(1, $content['user_id']);
} }
@ -504,8 +504,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertGreaterThan(0, $content['id']); $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('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(0, $content['is_archived']);
$this->assertSame(true, $content['is_starred']); $this->assertSame(1, $content['is_starred']);
} }
public function testPatchEntry() public function testPatchEntry()
@ -691,7 +691,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
$content = json_decode($this->client->getResponse()->getContent(), true); $content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertSame(true, $content['is_archived']); $this->assertSame(1, $content['is_archived']);
} }
public function testSaveIsStarredAfterPost() public function testSaveIsStarredAfterPost()
@ -713,7 +713,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
$content = json_decode($this->client->getResponse()->getContent(), true); $content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertSame(true, $content['is_starred']); $this->assertSame(1, $content['is_starred']);
} }
public function testSaveIsArchivedAfterPatch() public function testSaveIsArchivedAfterPatch()
@ -735,7 +735,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
$content = json_decode($this->client->getResponse()->getContent(), true); $content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertSame(true, $content['is_archived']); $this->assertSame(1, $content['is_archived']);
} }
public function testSaveIsStarredAfterPatch() public function testSaveIsStarredAfterPatch()
@ -756,7 +756,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
$content = json_decode($this->client->getResponse()->getContent(), true); $content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertSame(true, $content['is_starred']); $this->assertSame(1, $content['is_starred']);
} }
public function dataForEntriesExistWithUrl() public function dataForEntriesExistWithUrl()

View file

@ -43,6 +43,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client = $this->getClient(); $client = $this->getClient();
$client->request('GET', '/unread/list'); $client->request('GET', '/unread/list');
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect(); $crawler = $client->followRedirect();
$this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertSame(200, $client->getResponse()->getStatusCode());
@ -505,7 +506,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId()); ->find($entry->getId());
$this->assertSame($res->isArchived(), true); $this->assertSame(1, $res->isArchived());
} }
public function testToggleStar() public function testToggleStar()
@ -528,7 +529,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->findOneById($entry->getId()); ->findOneById($entry->getId());
$this->assertSame($res->isStarred(), true); $this->assertSame(1, $res->isStarred());
} }
public function testDelete() public function testDelete()
@ -1004,7 +1005,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame($url, $entry->getUrl()); $this->assertSame($url, $entry->getUrl());
$this->assertContains('Perpignan', $entry->getTitle()); $this->assertContains('Perpignan', $entry->getTitle());
// instead of checking for the filename (which might change) check that the image is now local // 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); $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
} }
@ -1296,7 +1297,7 @@ class EntryControllerTest extends WallabagCoreTestCase
], ],
'fucked_list_of_languages' => [ 'fucked_list_of_languages' => [
'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home', 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home',
'', null,
], ],
'es-ES' => [ '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',

View file

@ -230,8 +230,8 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertArrayHasKey('created_at', $content[0]); $this->assertArrayHasKey('created_at', $content[0]);
$this->assertArrayHasKey('updated_at', $content[0]); $this->assertArrayHasKey('updated_at', $content[0]);
$this->assertSame($contentInDB->isArchived(), $content[0]['is_archived']); $this->assertSame((int) $contentInDB->isArchived(), $content[0]['is_archived']);
$this->assertSame($contentInDB->isStarred(), $content[0]['is_starred']); $this->assertSame((int) $contentInDB->isStarred(), $content[0]['is_starred']);
$this->assertSame($contentInDB->getTitle(), $content[0]['title']); $this->assertSame($contentInDB->getTitle(), $content[0]['title']);
$this->assertSame($contentInDB->getUrl(), $content[0]['url']); $this->assertSame($contentInDB->getUrl(), $content[0]['url']);
$this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']); $this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);

View file

@ -53,6 +53,6 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
$listener->onInteractiveLogin($event); $listener->onInteractiveLogin($event);
$this->assertSame('', $session->get('_locale')); $this->assertNull($session->get('_locale'));
} }
} }

View file

@ -2,7 +2,6 @@
namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
use Graby\SiteConfig\SiteConfig as GrabySiteConfig; use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
use Monolog\Handler\TestHandler; use Monolog\Handler\TestHandler;
use Monolog\Logger; use Monolog\Logger;
@ -68,20 +67,15 @@ class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
$config = $this->builder->buildForHost('www.example.com'); $config = $this->builder->buildForHost('www.example.com');
$this->assertSame( $this->assertSame('example.com', $config->getHost());
new SiteConfig([ $this->assertSame(true, $config->requiresLogin());
'host' => 'example.com', $this->assertSame('http://www.example.com/login', $config->getLoginUri());
'requiresLogin' => true, $this->assertSame('login', $config->getUsernameField());
'loginUri' => 'http://www.example.com/login', $this->assertSame('password', $config->getPasswordField());
'usernameField' => 'login', $this->assertSame(['field' => 'value'], $config->getExtraFields());
'passwordField' => 'password', $this->assertSame('//div[@class="need-login"]', $config->getNotLoggedInXpath());
'extraFields' => ['field' => 'value'], $this->assertSame('foo', $config->getUsername());
'notLoggedInXpath' => '//div[@class="need-login"]', $this->assertSame('bar', $config->getPassword());
'username' => 'foo',
'password' => 'bar',
]),
$config
);
$records = $handler->getRecords(); $records = $handler->getRecords();

View file

@ -51,7 +51,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$this->assertEmpty($entry->getMimetype()); $this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage()); $this->assertEmpty($entry->getLanguage());
$this->assertSame(0.0, $entry->getReadingTime()); $this->assertSame(0.0, $entry->getReadingTime());
$this->assertSame(false, $entry->getDomainName()); $this->assertSame(null, $entry->getDomainName());
} }
public function testWithEmptyContent() public function testWithEmptyContent()