aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2019-01-18 15:56:39 +0100
committerGitHub <noreply@github.com>2019-01-18 15:56:39 +0100
commit6bfbf16eeb0004fcac6d2d2507e3d7d8b4dc3c1f (patch)
treeb4f38bf4a01580f5f7218440e7054688d7178e53
parent8445ad4790ff4f3f9759f9bfa0d503ad5654e30e (diff)
parent1e0d8ad7b728f6fb2cd886526b0fb84ef803e84f (diff)
downloadwallabag-6bfbf16eeb0004fcac6d2d2507e3d7d8b4dc3c1f.tar.gz
wallabag-6bfbf16eeb0004fcac6d2d2507e3d7d8b4dc3c1f.tar.zst
wallabag-6bfbf16eeb0004fcac6d2d2507e3d7d8b4dc3c1f.zip
Merge pull request #3859 from wallabag/phpstan
Enable PHPStan
-rw-r--r--.travis.yml2
-rw-r--r--app/DoctrineMigrations/Version20190117131816.php32
-rw-r--r--composer.json6
-rw-r--r--phpstan.neon13
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php3
-rw-r--r--src/Wallabag/CoreBundle/Entity/SiteCredential.php17
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php1
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php4
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php11
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RedirectTest.php3
-rw-r--r--tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php4
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php4
-rw-r--r--tests/Wallabag/UserBundle/Controller/ManageControllerTest.php2
-rw-r--r--tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php16
-rw-r--r--tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php19
27 files changed, 118 insertions, 43 deletions
diff --git a/.travis.yml b/.travis.yml
index 9d7fd3a0..ac64839d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -67,6 +67,8 @@ script:
67 - make fixtures 67 - make fixtures
68 68
69 - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then SYMFONY_PHPUNIT_VERSION=6.5 ./bin/simple-phpunit -v ; fi; 69 - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then SYMFONY_PHPUNIT_VERSION=6.5 ./bin/simple-phpunit -v ; fi;
70 # PHPStan needs PHPUnit to be installed and cache app to be generated
71 - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then php bin/phpstan analyse src tests --no-progress --level 1 ; fi;
70 - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix --verbose --dry-run ; fi; 72 - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix --verbose --dry-run ; fi;
71 - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi; 73 - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi;
72 - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml app/Resources/CraueConfigBundle/translations -v ; fi; 74 - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml app/Resources/CraueConfigBundle/translations -v ; fi;
diff --git a/app/DoctrineMigrations/Version20190117131816.php b/app/DoctrineMigrations/Version20190117131816.php
new file mode 100644
index 00000000..6548b9fa
--- /dev/null
+++ b/app/DoctrineMigrations/Version20190117131816.php
@@ -0,0 +1,32 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Add updated_at fields to site_credential table.
10 */
11final class Version20190117131816 extends WallabagMigration
12{
13 public function up(Schema $schema): void
14 {
15 $siteCredentialTable = $schema->getTable($this->getTable('site_credential'));
16
17 $this->skipIf($siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.');
18
19 $siteCredentialTable->addColumn('updated_at', 'datetime', [
20 'notnull' => false,
21 ]);
22 }
23
24 public function down(Schema $schema): void
25 {
26 $siteCredentialTable = $schema->getTable($this->getTable('site_credential'));
27
28 $this->skipIf(!$siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.');
29
30 $siteCredentialTable->dropColumn('updated_at');
31 }
32}
diff --git a/composer.json b/composer.json
index 8b28f065..89286c7f 100644
--- a/composer.json
+++ b/composer.json
@@ -92,7 +92,11 @@
92 "symfony/phpunit-bridge": "^4.2", 92 "symfony/phpunit-bridge": "^4.2",
93 "friendsofphp/php-cs-fixer": "~2.13", 93 "friendsofphp/php-cs-fixer": "~2.13",
94 "m6web/redis-mock": "^4.1", 94 "m6web/redis-mock": "^4.1",
95 "dama/doctrine-test-bundle": "^5.0" 95 "dama/doctrine-test-bundle": "^5.0",
96 "phpstan/phpstan": "^0.11.0",
97 "phpstan/phpstan-phpunit": "^0.11.0",
98 "phpstan/phpstan-symfony": "^0.11.0",
99 "phpstan/phpstan-doctrine": "^0.11.0"
96 }, 100 },
97 "scripts": { 101 "scripts": {
98 "post-cmd": [ 102 "post-cmd": [
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 00000000..dfbc97ac
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,13 @@
1includes:
2 - vendor/phpstan/phpstan-phpunit/extension.neon
3 - vendor/phpstan/phpstan-symfony/extension.neon
4 - vendor/phpstan/phpstan-doctrine/extension.neon
5 - vendor/phpstan/phpstan-phpunit/rules.neon
6
7parameters:
8 symfony:
9 container_xml_path: %rootDir%/../../../var/cache/test/appTestDebugProjectContainer.xml
10
11 # https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288
12 autoload_files:
13 - vendor/bin/.phpunit/phpunit-6.5/vendor/autoload.php
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 3c76545c..49c84178 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -94,8 +94,9 @@ class InstallCommand extends ContainerAwareCommand
94 $status = '<info>OK!</info>'; 94 $status = '<info>OK!</info>';
95 $help = ''; 95 $help = '';
96 96
97 $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
98
97 try { 99 try {
98 $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
99 $conn->connect(); 100 $conn->connect();
100 } catch (\Exception $e) { 101 } catch (\Exception $e) {
101 if (false === strpos($e->getMessage(), 'Unknown database') 102 if (false === strpos($e->getMessage(), 'Unknown database')
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
index ac714359..dee48fd5 100644
--- a/src/Wallabag/CoreBundle/Entity/SiteCredential.php
+++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
@@ -60,6 +60,13 @@ class SiteCredential
60 private $createdAt; 60 private $createdAt;
61 61
62 /** 62 /**
63 * @var \DateTime
64 *
65 * @ORM\Column(name="updated_at", type="datetime")
66 */
67 private $updatedAt;
68
69 /**
63 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="siteCredentials") 70 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="siteCredentials")
64 */ 71 */
65 private $user; 72 private $user;
@@ -179,6 +186,16 @@ class SiteCredential
179 } 186 }
180 187
181 /** 188 /**
189 * Get updatedAt.
190 *
191 * @return \DateTime
192 */
193 public function getUpdatedAt()
194 {
195 return $this->updatedAt;
196 }
197
198 /**
182 * @return User 199 * @return User
183 */ 200 */
184 public function getUser() 201 public function getUser()
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 63f65067..fbdf2ac7 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -6,6 +6,7 @@ use Psr\Log\LoggerInterface;
6use RulerZ\RulerZ; 6use RulerZ\RulerZ;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\CoreBundle\Entity\TaggingRule;
9use Wallabag\CoreBundle\Repository\EntryRepository; 10use Wallabag\CoreBundle\Repository\EntryRepository;
10use Wallabag\CoreBundle\Repository\TagRepository; 11use Wallabag\CoreBundle\Repository\TagRepository;
11use Wallabag\UserBundle\Entity\User; 12use Wallabag\UserBundle\Entity\User;
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
index 537283f2..2c46e0a1 100644
--- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
+++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\AnnotationBundle\Controller; 3namespace Tests\Wallabag\AnnotationBundle\Controller;
4 4
5use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase; 5use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase;
6use Wallabag\AnnotationBundle\Entity\Annotation; 6use Wallabag\AnnotationBundle\Entity\Annotation;
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 1a41338c..0b0c0276 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -794,7 +794,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
794 $content = json_decode($this->client->getResponse()->getContent(), true); 794 $content = json_decode($this->client->getResponse()->getContent(), true);
795 795
796 $this->assertArrayHasKey('tags', $content); 796 $this->assertArrayHasKey('tags', $content);
797 $this->assertSame($nbTags + 3, \count($content['tags'])); 797 $this->assertCount($nbTags + 3, $content['tags']);
798 798
799 $entryDB = $this->client->getContainer() 799 $entryDB = $this->client->getContainer()
800 ->get('doctrine.orm.entity_manager') 800 ->get('doctrine.orm.entity_manager')
@@ -834,7 +834,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
834 $content = json_decode($this->client->getResponse()->getContent(), true); 834 $content = json_decode($this->client->getResponse()->getContent(), true);
835 835
836 $this->assertArrayHasKey('tags', $content); 836 $this->assertArrayHasKey('tags', $content);
837 $this->assertSame($nbTags - 1, \count($content['tags'])); 837 $this->assertCount($nbTags - 1, $content['tags']);
838 } 838 }
839 839
840 public function testSaveIsArchivedAfterPost() 840 public function testSaveIsArchivedAfterPost()
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index cf9f1e97..c9dbbaa3 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace tests\Wallabag\CoreBundle\Controller; 3namespace Tests\Wallabag\CoreBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\AnnotationBundle\Entity\Annotation; 6use Wallabag\AnnotationBundle\Entity\Annotation;
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 006ca330..005296ff 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -522,9 +522,12 @@ class EntryControllerTest extends WallabagCoreTestCase
522 522
523 $crawler = $client->followRedirect(); 523 $crawler = $client->followRedirect();
524 524
525 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); 525 $title = $crawler->filter('div[id=article] h1')->extract(['_text']);
526 $this->assertGreaterThan(1, $title);
526 $this->assertContains('My updated title hehe :)', $title[0]); 527 $this->assertContains('My updated title hehe :)', $title[0]);
527 $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); 528
529 $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']);
530 $this->assertCount(1, $stats);
528 $this->assertNotContains('example.io', trim($stats[0])); 531 $this->assertNotContains('example.io', trim($stats[0]));
529 } 532 }
530 533
@@ -1327,10 +1330,6 @@ class EntryControllerTest extends WallabagCoreTestCase
1327 'http://www.hao123.com/shequ?__noscript__-=1', 1330 'http://www.hao123.com/shequ?__noscript__-=1',
1328 'zh_CN', 1331 'zh_CN',
1329 ], 1332 ],
1330 'ru' => [
1331 'https://www.kp.ru/daily/26879.7/3921982/',
1332 'ru',
1333 ],
1334 'pt_BR' => [ 1333 'pt_BR' => [
1335 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', 1334 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983',
1336 'pt_BR', 1335 'pt_BR',
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index 0c3d4c83..d7ce7c45 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase
180 180
181 $this->assertGreaterThan(1, $csv); 181 $this->assertGreaterThan(1, $csv);
182 // +1 for title line 182 // +1 for title line
183 $this->assertSame(\count($contentInDB) + 1, \count($csv)); 183 $this->assertCount(\count($contentInDB) + 1, $csv);
184 $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); 184 $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
185 $this->assertContains($contentInDB[0]['title'], $csv[1]); 185 $this->assertContains($contentInDB[0]['title'], $csv[1]);
186 $this->assertContains($contentInDB[0]['url'], $csv[1]); 186 $this->assertContains($contentInDB[0]['url'], $csv[1]);
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
index 2af6e14f..afa90621 100644
--- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
@@ -11,7 +11,7 @@ class RssControllerTest extends WallabagCoreTestCase
11 $doc = new \DOMDocument(); 11 $doc = new \DOMDocument();
12 $doc->loadXML($xml); 12 $doc->loadXML($xml);
13 13
14 $xpath = new \DOMXpath($doc); 14 $xpath = new \DOMXPath($doc);
15 15
16 if (null === $nb) { 16 if (null === $nb) {
17 $this->assertGreaterThan(0, $xpath->query('//item')->length); 17 $this->assertGreaterThan(0, $xpath->query('//item')->length);
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
index 04e1a59c..29e12cbe 100644
--- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
@@ -17,6 +17,9 @@ class RedirectTest extends TestCase
17 /** @var Redirect */ 17 /** @var Redirect */
18 private $redirect; 18 private $redirect;
19 19
20 /** @var UsernamePasswordToken */
21 private $token;
22
20 public function setUp() 23 public function setUp()
21 { 24 {
22 $this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router') 25 $this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router')
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
index b044a700..800af5c9 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\CoreBundle\Command; 3namespace Tests\Wallabag\CoreBundle\ParamConverter;
4 4
5use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
index b2141c04..b7f6192d 100644
--- a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; 3namespace Tests\Wallabag\ImportBundle\Consumer;
4 4
5use PhpAmqpLib\Message\AMQPMessage; 5use PhpAmqpLib\Message\AMQPMessage;
6use PHPUnit\Framework\TestCase; 6use PHPUnit\Framework\TestCase;
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
index 61337e47..e1bd8827 100644
--- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; 3namespace Tests\Wallabag\ImportBundle\Consumer;
4 4
5use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
6use Wallabag\CoreBundle\Entity\Entry; 6use Wallabag\CoreBundle\Entity\Entry;
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
index cd3e41e9..d3ffbb6d 100644
--- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
@@ -121,7 +121,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
121 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 121 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok');
124 $this->assertSame(1, \count($content->getTags())); 124 $this->assertCount(1, $content->getTags());
125 125
126 $createdAt = $content->getCreatedAt(); 126 $createdAt = $content->getCreatedAt();
127 $this->assertSame('2011', $createdAt->format('Y')); 127 $this->assertSame('2011', $createdAt->format('Y'));
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
index dc5ed6d0..3e64f2e5 100644
--- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
@@ -122,7 +122,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); 122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok');
123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); 123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok');
124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); 124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok');
125 $this->assertSame(3, \count($content->getTags())); 125 $this->assertCount(3, $content->getTags());
126 126
127 $content = $client->getContainer() 127 $content = $client->getContainer()
128 ->get('doctrine.orm.entity_manager') 128 ->get('doctrine.orm.entity_manager')
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
index 7390fa88..05347767 100644
--- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
@@ -124,7 +124,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
124 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok'); 124 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok');
125 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); 125 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok');
126 $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); 126 $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
127 $this->assertSame(1, \count($content->getTags())); 127 $this->assertCount(1, $content->getTags());
128 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 128 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
129 129
130 $content = $client->getContainer() 130 $content = $client->getContainer()
@@ -138,7 +138,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
138 $this->assertContains('foot', $content->getTags()); 138 $this->assertContains('foot', $content->getTags());
139 $this->assertContains('test_tag', $content->getTags()); 139 $this->assertContains('test_tag', $content->getTags());
140 140
141 $this->assertSame(2, \count($content->getTags())); 141 $this->assertCount(2, $content->getTags());
142 } 142 }
143 143
144 public function testImportInstapaperWithFileAndMarkAllAsRead() 144 public function testImportInstapaperWithFileAndMarkAllAsRead()
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
index 80819f45..15646d55 100644
--- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
@@ -127,7 +127,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
127 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 127 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
128 $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); 128 $this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
129 $this->assertContains('php', $tags, 'It includes the "php" tag'); 129 $this->assertContains('php', $tags, 'It includes the "php" tag');
130 $this->assertSame(3, \count($tags)); 130 $this->assertCount(3, $tags);
131 131
132 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 132 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
133 $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); 133 $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
index 5619659a..4f2f4053 100644
--- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
@@ -125,7 +125,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
125 125
126 $tags = $content->getTags(); 126 $tags = $content->getTags();
127 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 127 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
128 $this->assertSame(1, \count($tags)); 128 $this->assertCount(1, $tags);
129 129
130 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 130 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
131 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 131 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index c67941a7..1f57939d 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -127,7 +127,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
127 $tags = $content->getTags(); 127 $tags = $content->getTags();
128 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 128 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
129 $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); 129 $this->assertContains('framabag', $tags, 'It includes the "framabag" tag');
130 $this->assertSame(2, \count($tags)); 130 $this->assertCount(2, $tags);
131 131
132 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 132 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
133 } 133 }
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index 822656ba..b606e26a 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -128,7 +128,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
128 128
129 $tags = $content->getTags(); 129 $tags = $content->getTags();
130 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 130 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
131 $this->assertSame(1, \count($tags)); 131 $this->assertCount(1, $tags);
132 132
133 $content = $client->getContainer() 133 $content = $client->getContainer()
134 ->get('doctrine.orm.entity_manager') 134 ->get('doctrine.orm.entity_manager')
@@ -147,7 +147,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
147 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 147 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
148 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); 148 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
149 $this->assertContains('blog', $tags, 'It includes the "blog" tag'); 149 $this->assertContains('blog', $tags, 'It includes the "blog" tag');
150 $this->assertSame(3, \count($tags)); 150 $this->assertCount(3, $tags);
151 151
152 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 152 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
153 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 153 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
index adc2cf09..f44e6fbf 100644
--- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
+++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Wallabag\UserBundle\Tests\Controller; 3namespace Tests\Wallabag\UserBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6 6
diff --git a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
index aa176068..e34e13a8 100644
--- a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
+++ b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
@@ -6,22 +6,6 @@ use PHPUnit\Framework\TestCase;
6use Wallabag\UserBundle\Entity\User; 6use Wallabag\UserBundle\Entity\User;
7use Wallabag\UserBundle\Mailer\AuthCodeMailer; 7use Wallabag\UserBundle\Mailer\AuthCodeMailer;
8 8
9/**
10 * @see https://www.pmg.com/blog/integration-testing-swift-mailer/
11 */
12final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable
13{
14 public function count()
15 {
16 return \count($this->messages);
17 }
18
19 public function getMessages()
20 {
21 return $this->messages;
22 }
23}
24
25class AuthCodeMailerTest extends TestCase 9class AuthCodeMailerTest extends TestCase
26{ 10{
27 protected $mailer; 11 protected $mailer;
diff --git a/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php
new file mode 100644
index 00000000..53f240a1
--- /dev/null
+++ b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php
@@ -0,0 +1,19 @@
1<?php
2
3namespace Tests\Wallabag\UserBundle\Mailer;
4
5/**
6 * @see https://www.pmg.com/blog/integration-testing-swift-mailer/
7 */
8final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable
9{
10 public function count()
11 {
12 return \count($this->messages);
13 }
14
15 public function getMessages()
16 {
17 return $this->messages;
18 }
19}