- make fixtures
- if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then SYMFONY_PHPUNIT_VERSION=6.5 ./bin/simple-phpunit -v ; fi;
+ # PHPStan needs PHPUnit to be installed and cache app to be generated
+ - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then php bin/phpstan analyse src tests --no-progress --level 1 ; 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;
--- /dev/null
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Wallabag\CoreBundle\Doctrine\WallabagMigration;
+
+/**
+ * Add updated_at fields to site_credential table.
+ */
+final class Version20190117131816 extends WallabagMigration
+{
+ public function up(Schema $schema): void
+ {
+ $siteCredentialTable = $schema->getTable($this->getTable('site_credential'));
+
+ $this->skipIf($siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.');
+
+ $siteCredentialTable->addColumn('updated_at', 'datetime', [
+ 'notnull' => false,
+ ]);
+ }
+
+ public function down(Schema $schema): void
+ {
+ $siteCredentialTable = $schema->getTable($this->getTable('site_credential'));
+
+ $this->skipIf(!$siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.');
+
+ $siteCredentialTable->dropColumn('updated_at');
+ }
+}
"symfony/phpunit-bridge": "^4.2",
"friendsofphp/php-cs-fixer": "~2.13",
"m6web/redis-mock": "^4.1",
- "dama/doctrine-test-bundle": "^5.0"
+ "dama/doctrine-test-bundle": "^5.0",
+ "phpstan/phpstan": "^0.11.0",
+ "phpstan/phpstan-phpunit": "^0.11.0",
+ "phpstan/phpstan-symfony": "^0.11.0",
+ "phpstan/phpstan-doctrine": "^0.11.0"
},
"scripts": {
"post-cmd": [
--- /dev/null
+includes:
+ - vendor/phpstan/phpstan-phpunit/extension.neon
+ - vendor/phpstan/phpstan-symfony/extension.neon
+ - vendor/phpstan/phpstan-doctrine/extension.neon
+ - vendor/phpstan/phpstan-phpunit/rules.neon
+
+parameters:
+ symfony:
+ container_xml_path: %rootDir%/../../../var/cache/test/appTestDebugProjectContainer.xml
+
+ # https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288
+ autoload_files:
+ - vendor/bin/.phpunit/phpunit-6.5/vendor/autoload.php
$status = '<info>OK!</info>';
$help = '';
+ $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
+
try {
- $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
$conn->connect();
} catch (\Exception $e) {
if (false === strpos($e->getMessage(), 'Unknown database')
*/
private $createdAt;
+ /**
+ * @var \DateTime
+ *
+ * @ORM\Column(name="updated_at", type="datetime")
+ */
+ private $updatedAt;
+
/**
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="siteCredentials")
*/
return $this->createdAt;
}
+ /**
+ * Get updatedAt.
+ *
+ * @return \DateTime
+ */
+ public function getUpdatedAt()
+ {
+ return $this->updatedAt;
+ }
+
/**
* @return User
*/
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Entity\TaggingRule;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
<?php
-namespace Tests\AnnotationBundle\Controller;
+namespace Tests\Wallabag\AnnotationBundle\Controller;
use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase;
use Wallabag\AnnotationBundle\Entity\Annotation;
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('tags', $content);
- $this->assertSame($nbTags + 3, \count($content['tags']));
+ $this->assertCount($nbTags + 3, $content['tags']);
$entryDB = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('tags', $content);
- $this->assertSame($nbTags - 1, \count($content['tags']));
+ $this->assertCount($nbTags - 1, $content['tags']);
}
public function testSaveIsArchivedAfterPost()
<?php
-namespace tests\Wallabag\CoreBundle\Controller;
+namespace Tests\Wallabag\CoreBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\AnnotationBundle\Entity\Annotation;
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
+ $title = $crawler->filter('div[id=article] h1')->extract(['_text']);
+ $this->assertGreaterThan(1, $title);
$this->assertContains('My updated title hehe :)', $title[0]);
- $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])));
+
+ $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']);
+ $this->assertCount(1, $stats);
$this->assertNotContains('example.io', trim($stats[0]));
}
'http://www.hao123.com/shequ?__noscript__-=1',
'zh_CN',
],
- 'ru' => [
- 'https://www.kp.ru/daily/26879.7/3921982/',
- 'ru',
- ],
'pt_BR' => [
'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983',
'pt_BR',
$this->assertGreaterThan(1, $csv);
// +1 for title line
- $this->assertSame(\count($contentInDB) + 1, \count($csv));
+ $this->assertCount(\count($contentInDB) + 1, $csv);
$this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
$this->assertContains($contentInDB[0]['title'], $csv[1]);
$this->assertContains($contentInDB[0]['url'], $csv[1]);
$doc = new \DOMDocument();
$doc->loadXML($xml);
- $xpath = new \DOMXpath($doc);
+ $xpath = new \DOMXPath($doc);
if (null === $nb) {
$this->assertGreaterThan(0, $xpath->query('//item')->length);
/** @var Redirect */
private $redirect;
+ /** @var UsernamePasswordToken */
+ private $token;
+
public function setUp()
{
$this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router')
<?php
-namespace Tests\Wallabag\CoreBundle\Command;
+namespace Tests\Wallabag\CoreBundle\ParamConverter;
use PHPUnit\Framework\TestCase;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
<?php
-namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
+namespace Tests\Wallabag\ImportBundle\Consumer;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;
<?php
-namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
+namespace Tests\Wallabag\ImportBundle\Consumer;
use PHPUnit\Framework\TestCase;
use Wallabag\CoreBundle\Entity\Entry;
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok');
- $this->assertSame(1, \count($content->getTags()));
+ $this->assertCount(1, $content->getTags());
$createdAt = $content->getCreatedAt();
$this->assertSame('2011', $createdAt->format('Y'));
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok');
- $this->assertSame(3, \count($content->getTags()));
+ $this->assertCount(3, $content->getTags());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok');
$this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
- $this->assertSame(1, \count($content->getTags()));
+ $this->assertCount(1, $content->getTags());
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$content = $client->getContainer()
$this->assertContains('foot', $content->getTags());
$this->assertContains('test_tag', $content->getTags());
- $this->assertSame(2, \count($content->getTags()));
+ $this->assertCount(2, $content->getTags());
}
public function testImportInstapaperWithFileAndMarkAllAsRead()
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
$this->assertContains('php', $tags, 'It includes the "php" tag');
- $this->assertSame(3, \count($tags));
+ $this->assertCount(3, $tags);
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
- $this->assertSame(1, \count($tags));
+ $this->assertCount(1, $tags);
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('framabag', $tags, 'It includes the "framabag" tag');
- $this->assertSame(2, \count($tags));
+ $this->assertCount(2, $tags);
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
}
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
- $this->assertSame(1, \count($tags));
+ $this->assertCount(1, $tags);
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
$this->assertContains('blog', $tags, 'It includes the "blog" tag');
- $this->assertSame(3, \count($tags));
+ $this->assertCount(3, $tags);
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
<?php
-namespace Wallabag\UserBundle\Tests\Controller;
+namespace Tests\Wallabag\UserBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Mailer\AuthCodeMailer;
-/**
- * @see https://www.pmg.com/blog/integration-testing-swift-mailer/
- */
-final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable
-{
- public function count()
- {
- return \count($this->messages);
- }
-
- public function getMessages()
- {
- return $this->messages;
- }
-}
-
class AuthCodeMailerTest extends TestCase
{
protected $mailer;
--- /dev/null
+<?php
+
+namespace Tests\Wallabag\UserBundle\Mailer;
+
+/**
+ * @see https://www.pmg.com/blog/integration-testing-swift-mailer/
+ */
+final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable
+{
+ public function count()
+ {
+ return \count($this->messages);
+ }
+
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+}