From 3c7900d0cdc8e1893a14bbdde5a6dec4e4186a10 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Oct 2018 20:26:18 +0200 Subject: Jump to PHP 7.1+ --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6d5415ab..4f234861 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "issues": "https://github.com/wallabag/wallabag/issues" }, "require": { - "php": ">=5.6.0", + "php": ">=7.1.0", "ext-pcre": "*", "ext-dom": "*", "ext-curl": "*", @@ -48,7 +48,7 @@ "doctrine/doctrine-bundle": "^1.8.0", "doctrine/doctrine-cache-bundle": "^1.3.2", "twig/extensions": "^1.5.1", - "symfony/swiftmailer-bundle": "^2.6.7", + "symfony/swiftmailer-bundle": "^3.2.3", "symfony/monolog-bundle": "^3.1.2", "sensio/distribution-bundle": "^5.0.21", "sensio/framework-extra-bundle": "^5.2.1", @@ -131,7 +131,7 @@ "config": { "bin-dir": "bin", "platform": { - "php": "5.6.0" + "php": "7.1.0" } }, "minimum-stability": "dev", -- cgit v1.2.3 From 0f159f8fc1dea68552dbfa845fa9a24a95953018 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Oct 2018 20:33:46 +0200 Subject: Fix RulerZBundle People should really follow semver and provide UPGRADE file when they provide a library ... --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 84e11e26..c1be3165 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -3,7 +3,7 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; +use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert; use Symfony\Component\Validator\Constraints as Assert; /** -- cgit v1.2.3 From 6fc95673df5349d682eb6ca6185f894eb711d13a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Oct 2018 21:02:35 +0200 Subject: Cleanup --- .travis.yml | 16 ++---------- .zappr.yaml | 26 ------------------- COPYING.md | 2 +- README.md | 6 ++--- app/AppKernel.php | 22 +++++++++++++--- app/autoload.php | 13 ---------- bin/console | 12 ++++----- composer.json | 29 ++++++++++++++++------ phpunit.xml.dist | 4 +-- .../CoreBundle/Doctrine/WallabagMigration.php | 2 +- web/app.php | 7 +----- web/app_dev.php | 12 +++------ 12 files changed, 60 insertions(+), 91 deletions(-) delete mode 100644 .zappr.yaml delete mode 100644 app/autoload.php diff --git a/.travis.yml b/.travis.yml index 39306343..60721f61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,6 @@ cache: - $HOME/.yarn-cache php: - - 5.6 - - 7.0 - 7.1 - 7.2 - nightly @@ -38,7 +36,7 @@ env: matrix: fast_finish: true include: - - php: 7.0 + - php: 7.2 env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite allow_failures: - php: nightly @@ -63,14 +61,6 @@ before_script: - if [[ ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi - composer self-update --no-progress - if [[ $DB = pgsql ]]; then psql -c 'create database wallabag_test;' -U postgres; fi; - # increase swap to avoid "proc_open(): fork failed - Cannot allocate memory" - # this should be removed when no more PHP 5 build will be defined - - sudo swapon -s - - sudo fallocate -l 4G /swapfile - - sudo chmod 600 /swapfile - - sudo mkswap /swapfile - - sudo swapon /swapfile - - sudo swapon -s script: - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist @@ -78,9 +68,7 @@ script: - make prepare DB=$DB - echo "travis_fold:end:prepare" - - echo "travis_fold:start:fixtures" - - php bin/console doctrine:fixtures:load --no-interaction --env=test - - echo "travis_fold:end:fixtures" + - make fixtures - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then ./bin/simple-phpunit -v ; fi; - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix --verbose --dry-run ; fi; diff --git a/.zappr.yaml b/.zappr.yaml deleted file mode 100644 index f90cd809..00000000 --- a/.zappr.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# see https://zappr.opensource.zalan.do/ -autobranch: false -commit: false -approvals: - minimum: 1 - ignore: pr_opener - pattern: "^(:\\+1:|👍)$" - veto: - pattern: "^(:\\-1:|👎)$" - from: - orgs: - - wallabag - collaborators: true -specification: - title: - minimum-length: - enabled: true - length: 8 - body: - minimum-length: - enabled: true - length: 8 - contains-url: false - contains-issue-number: false - template: - differs-from-body: true diff --git a/COPYING.md b/COPYING.md index 6be863d3..72b9d5d0 100644 --- a/COPYING.md +++ b/COPYING.md @@ -1,4 +1,4 @@ -Copyright (c) 2013-2017 Nicolas Lœuillet +Copyright (c) 2013-current Nicolas Lœuillet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 57392da2..e00c7ea0 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ Then you can install wallabag by executing the following commands: ``` git clone https://github.com/wallabag/wallabag.git -cd wallabag && make install +cd wallabag && make install ``` -Now, [configure a virtual host](https://doc.wallabag.org/en/admin/installation/virtualhosts.html) to use your wallabag. +Now, [configure a virtual host](https://doc.wallabag.org/en/admin/installation/virtualhosts.html) to use your wallabag. # Run on YunoHost [![Install Wallabag with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=wallabag2) @@ -30,6 +30,6 @@ Now, [configure a virtual host](https://doc.wallabag.org/en/admin/installation/v Wallabag app for [YunoHost](https://yunohost.org). See [here](https://github.com/YunoHost-Apps/wallabag2_ynh) # License -Copyright © 2013-2018 Nicolas Lœuillet +Copyright © 2013-current Nicolas Lœuillet This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the COPYING file for more details. diff --git a/app/AppKernel.php b/app/AppKernel.php index 546794de..7d19e9ab 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -1,6 +1,7 @@ getEnvironment()) { $bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle(); } + + if ('dev' === $this->getEnvironment()) { + $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); + $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); + } } return $bundles; } + public function getRootDir() + { + return __DIR__; + } + public function getCacheDir() { return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment(); @@ -70,7 +79,8 @@ class AppKernel extends Kernel public function registerContainerConfiguration(LoaderInterface $loader) { - $loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml'); + $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); + $loader->load(function ($container) { if ($container->getParameter('use_webpack_dev_server')) { $container->loadFromExtension('framework', [ @@ -86,5 +96,11 @@ class AppKernel extends Kernel ]); } }); + + $loader->load(function (ContainerBuilder $container) { + // $container->setParameter('container.autowiring.strict_mode', true); + // $container->setParameter('container.dumper.inline_class_loader', true); + $container->addObjectResource($this); + }); } } diff --git a/app/autoload.php b/app/autoload.php deleted file mode 100644 index c5f664dc..00000000 --- a/app/autoload.php +++ /dev/null @@ -1,13 +0,0 @@ -getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); -$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; +$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true); +$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod'; if ($debug) { Debug::enable(); diff --git a/composer.json b/composer.json index 4f234861..da2bd3b9 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,7 @@ "jms/serializer-bundle": "~2.2", "nelmio/api-doc-bundle": "^2.13.2", "mgargano/simplehtmldom": "~1.5", - "wallabag/tcpdf": "^6.2.15", + "wallabag/tcpdf": "^6.2.26", "simplepie/simplepie": "~1.5", "willdurand/hateoas-bundle": "~1.3", "liip/theme-bundle": "^1.4.6", @@ -68,7 +68,7 @@ "friendsofsymfony/oauth-server-bundle": "^1.5.2", "stof/doctrine-extensions-bundle": "^1.2", "scheb/two-factor-bundle": "^2.14.0", - "grandt/phpepub": "^4.0.7", + "grandt/phpepub": "dev-master", "wallabag/php-mobi": "~1.0.0", "kphoen/rulerz-bundle": "~0.13", "guzzlehttp/guzzle": "^5.3.1", @@ -122,18 +122,33 @@ } }, "autoload": { - "psr-4": { "Wallabag\\": "src/Wallabag/" }, - "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] + "psr-4": { + "Wallabag\\": "src/Wallabag/" + }, + "classmap": [ + "app/AppKernel.php", + "app/AppCache.php" + ] }, "autoload-dev": { - "psr-4": { "Tests\\": "tests/" } + "psr-4": { + "Tests\\": "tests/" + }, + "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ] }, "config": { "bin-dir": "bin", "platform": { - "php": "7.1.0" + "php": "7.1" } }, "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/Daniel-KM/PHPePub", + "comment": "The most up-to-date PHPePub as of now" + } + ] } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 951b5a14..426a5e72 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" backupGlobals="false" colors="true" - bootstrap="app/autoload.php" + bootstrap="vendor/autoload.php" > @@ -15,7 +15,7 @@ - + diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php index 7aa2409a..4a3fef3b 100644 --- a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php +++ b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php @@ -2,8 +2,8 @@ namespace Wallabag\CoreBundle\Doctrine; -use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/web/app.php b/web/app.php index 4c2c4650..3427e133 100644 --- a/web/app.php +++ b/web/app.php @@ -2,14 +2,9 @@ use Symfony\Component\HttpFoundation\Request; -/** - * @var Composer\Autoload\ClassLoader - */ -$loader = require __DIR__.'/../app/autoload.php'; -include_once __DIR__.'/../var/bootstrap.php.cache'; +require __DIR__.'/../vendor/autoload.php'; $kernel = new AppKernel('prod', false); -$kernel->loadClassCache(); //$kernel = new AppCache($kernel); // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter diff --git a/web/app_dev.php b/web/app_dev.php index 8456754d..57e1a433 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -1,10 +1,10 @@ loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); -- cgit v1.2.3 From 9394e8098a92c849d15c43dcd0c338887bff68ce Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Oct 2018 22:16:45 +0200 Subject: Jump to unrelease predis To fix deprecated message regarding `each()` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index da2bd3b9..8b31085b 100644 --- a/composer.json +++ b/composer.json @@ -79,7 +79,7 @@ "ocramius/proxy-manager": "^1.0.2", "white-october/pagerfanta-bundle": "^1.1.0", "php-amqplib/rabbitmq-bundle": "^1.14", - "predis/predis": "^1.1.1", + "predis/predis": "v1.1.x-dev", "javibravo/simpleue": "^2.0", "symfony/dom-crawler": "^3.3.13", "friendsofsymfony/jsrouting-bundle": "^2.2.1", -- cgit v1.2.3 From db9b6d8d0d9f943fe321ea690701662dac828e94 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 20:00:01 +0100 Subject: Update fixtures --- app/config/services_test.yml | 12 +- .../DataFixtures/AnnotationFixtures.php | 50 +++++++++ .../DataFixtures/ORM/LoadAnnotationData.php | 45 -------- .../CoreBundle/DataFixtures/ConfigFixtures.php | 70 ++++++++++++ .../CoreBundle/DataFixtures/EntryFixtures.php | 123 +++++++++++++++++++++ .../CoreBundle/DataFixtures/ORM/LoadConfigData.php | 67 ----------- .../CoreBundle/DataFixtures/ORM/LoadEntryData.php | 119 -------------------- .../DataFixtures/ORM/LoadSettingData.php | 47 -------- .../DataFixtures/ORM/LoadSiteCredentialData.php | 34 ------ .../CoreBundle/DataFixtures/ORM/LoadTagData.php | 55 --------- .../DataFixtures/ORM/LoadTaggingRuleData.php | 56 ---------- .../CoreBundle/DataFixtures/SettingFixtures.php | 39 +++++++ .../DataFixtures/SiteCredentialFixtures.php | 37 +++++++ .../CoreBundle/DataFixtures/TagFixtures.php | 47 ++++++++ .../DataFixtures/TaggingRuleFixtures.php | 58 ++++++++++ .../UserBundle/DataFixtures/ORM/LoadUserData.php | 61 ---------- .../UserBundle/DataFixtures/UserFixtures.php | 52 +++++++++ 17 files changed, 482 insertions(+), 490 deletions(-) create mode 100644 src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php delete mode 100644 src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php delete mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php create mode 100644 src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php delete mode 100644 src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php create mode 100644 src/Wallabag/UserBundle/DataFixtures/UserFixtures.php diff --git a/app/config/services_test.yml b/app/config/services_test.yml index a300f75d..1b3aff63 100644 --- a/app/config/services_test.yml +++ b/app/config/services_test.yml @@ -22,17 +22,17 @@ services: - "%kernel.cache_dir%/doctrine/metadata" # fixtures - Wallabag\AnnotationBundle\DataFixtures\ORM\: - resource: '../../src/Wallabag/AnnotationBundle/DataFixtures/ORM/*' + Wallabag\UserBundle\DataFixtures\: + resource: '../../src/Wallabag/UserBundle/DataFixtures/*' tags: ['doctrine.fixture.orm'] autowire: true - Wallabag\CoreBundle\DataFixtures\ORM\: - resource: '../../src/Wallabag/CoreBundle/DataFixtures/ORM/*' + Wallabag\CoreBundle\DataFixtures\: + resource: '../../src/Wallabag/CoreBundle/DataFixtures/*' tags: ['doctrine.fixture.orm'] autowire: true - Wallabag\UserBundle\DataFixtures\ORM\: - resource: '../../src/Wallabag/UserBundle/DataFixtures/ORM/*' + Wallabag\AnnotationBundle\DataFixtures\: + resource: '../../src/Wallabag/AnnotationBundle/DataFixtures/*' tags: ['doctrine.fixture.orm'] autowire: true diff --git a/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php b/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php new file mode 100644 index 00000000..ed46cea9 --- /dev/null +++ b/src/Wallabag/AnnotationBundle/DataFixtures/AnnotationFixtures.php @@ -0,0 +1,50 @@ +getReference('admin-user')); + $annotation1->setEntry($this->getReference('entry1')); + $annotation1->setText('This is my annotation /o/'); + $annotation1->setQuote('content'); + + $manager->persist($annotation1); + + $this->addReference('annotation1', $annotation1); + + $annotation2 = new Annotation($this->getReference('admin-user')); + $annotation2->setEntry($this->getReference('entry2')); + $annotation2->setText('This is my 2nd annotation /o/'); + $annotation2->setQuote('content'); + + $manager->persist($annotation2); + + $this->addReference('annotation2', $annotation2); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + EntryFixtures::class, + UserFixtures::class, + ]; + } +} diff --git a/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php b/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php deleted file mode 100644 index 20e07fa3..00000000 --- a/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php +++ /dev/null @@ -1,45 +0,0 @@ -getReference('admin-user')); - $annotation1->setEntry($this->getReference('entry1')); - $annotation1->setText('This is my annotation /o/'); - $annotation1->setQuote('content'); - - $manager->persist($annotation1); - - $this->addReference('annotation1', $annotation1); - - $annotation2 = new Annotation($this->getReference('admin-user')); - $annotation2->setEntry($this->getReference('entry2')); - $annotation2->setText('This is my 2nd annotation /o/'); - $annotation2->setQuote('content'); - - $manager->persist($annotation2); - - $this->addReference('annotation2', $annotation2); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 35; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php new file mode 100644 index 00000000..c54e9f2c --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php @@ -0,0 +1,70 @@ +getReference('admin-user')); + + $adminConfig->setTheme('material'); + $adminConfig->setItemsPerPage(30); + $adminConfig->setReadingSpeed(1); + $adminConfig->setLanguage('en'); + $adminConfig->setPocketConsumerKey('xxxxx'); + $adminConfig->setActionMarkAsRead(0); + $adminConfig->setListMode(0); + + $manager->persist($adminConfig); + + $this->addReference('admin-config', $adminConfig); + + $bobConfig = new Config($this->getReference('bob-user')); + $bobConfig->setTheme('default'); + $bobConfig->setItemsPerPage(10); + $bobConfig->setReadingSpeed(1); + $bobConfig->setLanguage('fr'); + $bobConfig->setPocketConsumerKey(null); + $bobConfig->setActionMarkAsRead(1); + $bobConfig->setListMode(1); + + $manager->persist($bobConfig); + + $this->addReference('bob-config', $bobConfig); + + $emptyConfig = new Config($this->getReference('empty-user')); + $emptyConfig->setTheme('material'); + $emptyConfig->setItemsPerPage(10); + $emptyConfig->setReadingSpeed(1); + $emptyConfig->setLanguage('en'); + $emptyConfig->setPocketConsumerKey(null); + $emptyConfig->setActionMarkAsRead(0); + $emptyConfig->setListMode(0); + + $manager->persist($emptyConfig); + + $this->addReference('empty-config', $emptyConfig); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + UserFixtures::class, + ]; + } +} diff --git a/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php new file mode 100644 index 00000000..0bd58487 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php @@ -0,0 +1,123 @@ +getReference('admin-user')); + $entry1->setUrl('http://0.0.0.0/entry1'); + $entry1->setReadingTime(11); + $entry1->setDomainName('domain.io'); + $entry1->setMimetype('text/html'); + $entry1->setTitle('test title entry1'); + $entry1->setContent('This is my content /o/'); + $entry1->setLanguage('en'); + + $entry1->addTag($this->getReference('foo-tag')); + $entry1->addTag($this->getReference('baz-tag')); + + $manager->persist($entry1); + + $this->addReference('entry1', $entry1); + + $entry2 = new Entry($this->getReference('admin-user')); + $entry2->setUrl('http://0.0.0.0/entry2'); + $entry2->setReadingTime(1); + $entry2->setDomainName('domain.io'); + $entry2->setMimetype('text/html'); + $entry2->setTitle('test title entry2'); + $entry2->setContent('This is my content /o/'); + $entry2->setOriginUrl('ftp://oneftp.tld'); + $entry2->setLanguage('fr'); + + $manager->persist($entry2); + + $this->addReference('entry2', $entry2); + + $entry3 = new Entry($this->getReference('bob-user')); + $entry3->setUrl('http://0.0.0.0/entry3'); + $entry3->setReadingTime(1); + $entry3->setDomainName('domain.io'); + $entry3->setMimetype('text/html'); + $entry3->setTitle('test title entry3'); + $entry3->setContent('This is my content /o/'); + $entry3->setLanguage('en'); + + $entry3->addTag($this->getReference('foo-tag')); + $entry3->addTag($this->getReference('bar-tag')); + + $manager->persist($entry3); + + $this->addReference('entry3', $entry3); + + $entry4 = new Entry($this->getReference('admin-user')); + $entry4->setUrl('http://0.0.0.0/entry4'); + $entry4->setReadingTime(12); + $entry4->setDomainName('domain.io'); + $entry4->setMimetype('text/html'); + $entry4->setTitle('test title entry4'); + $entry4->setContent('This is my content /o/'); + $entry4->setLanguage('en'); + + $entry4->addTag($this->getReference('foo-tag')); + $entry4->addTag($this->getReference('bar-tag')); + + $manager->persist($entry4); + + $this->addReference('entry4', $entry4); + + $entry5 = new Entry($this->getReference('admin-user')); + $entry5->setUrl('http://0.0.0.0/entry5'); + $entry5->setReadingTime(12); + $entry5->setDomainName('domain.io'); + $entry5->setMimetype('text/html'); + $entry5->setTitle('test title entry5'); + $entry5->setContent('This is my content /o/'); + $entry5->setStarred(true); + $entry5->setLanguage('fr'); + $entry5->setPreviewPicture('http://0.0.0.0/image.jpg'); + + $manager->persist($entry5); + + $this->addReference('entry5', $entry5); + + $entry6 = new Entry($this->getReference('admin-user')); + $entry6->setUrl('http://0.0.0.0/entry6'); + $entry6->setReadingTime(12); + $entry6->setDomainName('domain.io'); + $entry6->setMimetype('text/html'); + $entry6->setTitle('test title entry6'); + $entry6->setContent('This is my content /o/'); + $entry6->updateArchived(true); + $entry6->setLanguage('de'); + $entry6->addTag($this->getReference('bar-tag')); + + $manager->persist($entry6); + + $this->addReference('entry6', $entry6); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + UserFixtures::class, + TagFixtures::class, + ]; + } +} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php deleted file mode 100644 index 3d4d5def..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php +++ /dev/null @@ -1,67 +0,0 @@ -getReference('admin-user')); - - $adminConfig->setTheme('material'); - $adminConfig->setItemsPerPage(30); - $adminConfig->setReadingSpeed(1); - $adminConfig->setLanguage('en'); - $adminConfig->setPocketConsumerKey('xxxxx'); - $adminConfig->setActionMarkAsRead(0); - $adminConfig->setListMode(0); - - $manager->persist($adminConfig); - - $this->addReference('admin-config', $adminConfig); - - $bobConfig = new Config($this->getReference('bob-user')); - $bobConfig->setTheme('default'); - $bobConfig->setItemsPerPage(10); - $bobConfig->setReadingSpeed(1); - $bobConfig->setLanguage('fr'); - $bobConfig->setPocketConsumerKey(null); - $bobConfig->setActionMarkAsRead(1); - $bobConfig->setListMode(1); - - $manager->persist($bobConfig); - - $this->addReference('bob-config', $bobConfig); - - $emptyConfig = new Config($this->getReference('empty-user')); - $emptyConfig->setTheme('material'); - $emptyConfig->setItemsPerPage(10); - $emptyConfig->setReadingSpeed(1); - $emptyConfig->setLanguage('en'); - $emptyConfig->setPocketConsumerKey(null); - $emptyConfig->setActionMarkAsRead(0); - $emptyConfig->setListMode(0); - - $manager->persist($emptyConfig); - - $this->addReference('empty-config', $emptyConfig); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 20; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php deleted file mode 100644 index 62fb5fa6..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ /dev/null @@ -1,119 +0,0 @@ -getReference('admin-user')); - $entry1->setUrl('http://0.0.0.0/entry1'); - $entry1->setReadingTime(11); - $entry1->setDomainName('domain.io'); - $entry1->setMimetype('text/html'); - $entry1->setTitle('test title entry1'); - $entry1->setContent('This is my content /o/'); - $entry1->setLanguage('en'); - - $entry1->addTag($this->getReference('foo-tag')); - $entry1->addTag($this->getReference('baz-tag')); - - $manager->persist($entry1); - - $this->addReference('entry1', $entry1); - - $entry2 = new Entry($this->getReference('admin-user')); - $entry2->setUrl('http://0.0.0.0/entry2'); - $entry2->setReadingTime(1); - $entry2->setDomainName('domain.io'); - $entry2->setMimetype('text/html'); - $entry2->setTitle('test title entry2'); - $entry2->setContent('This is my content /o/'); - $entry2->setOriginUrl('ftp://oneftp.tld'); - $entry2->setLanguage('fr'); - - $manager->persist($entry2); - - $this->addReference('entry2', $entry2); - - $entry3 = new Entry($this->getReference('bob-user')); - $entry3->setUrl('http://0.0.0.0/entry3'); - $entry3->setReadingTime(1); - $entry3->setDomainName('domain.io'); - $entry3->setMimetype('text/html'); - $entry3->setTitle('test title entry3'); - $entry3->setContent('This is my content /o/'); - $entry3->setLanguage('en'); - - $entry3->addTag($this->getReference('foo-tag')); - $entry3->addTag($this->getReference('bar-tag')); - - $manager->persist($entry3); - - $this->addReference('entry3', $entry3); - - $entry4 = new Entry($this->getReference('admin-user')); - $entry4->setUrl('http://0.0.0.0/entry4'); - $entry4->setReadingTime(12); - $entry4->setDomainName('domain.io'); - $entry4->setMimetype('text/html'); - $entry4->setTitle('test title entry4'); - $entry4->setContent('This is my content /o/'); - $entry4->setLanguage('en'); - - $entry4->addTag($this->getReference('foo-tag')); - $entry4->addTag($this->getReference('bar-tag')); - - $manager->persist($entry4); - - $this->addReference('entry4', $entry4); - - $entry5 = new Entry($this->getReference('admin-user')); - $entry5->setUrl('http://0.0.0.0/entry5'); - $entry5->setReadingTime(12); - $entry5->setDomainName('domain.io'); - $entry5->setMimetype('text/html'); - $entry5->setTitle('test title entry5'); - $entry5->setContent('This is my content /o/'); - $entry5->setStarred(true); - $entry5->setLanguage('fr'); - $entry5->setPreviewPicture('http://0.0.0.0/image.jpg'); - - $manager->persist($entry5); - - $this->addReference('entry5', $entry5); - - $entry6 = new Entry($this->getReference('admin-user')); - $entry6->setUrl('http://0.0.0.0/entry6'); - $entry6->setReadingTime(12); - $entry6->setDomainName('domain.io'); - $entry6->setMimetype('text/html'); - $entry6->setTitle('test title entry6'); - $entry6->setContent('This is my content /o/'); - $entry6->updateArchived(true); - $entry6->setLanguage('de'); - $entry6->addTag($this->getReference('bar-tag')); - - $manager->persist($entry6); - - $this->addReference('entry6', $entry6); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 30; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php deleted file mode 100644 index 3fe88e7f..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php +++ /dev/null @@ -1,47 +0,0 @@ -container = $container; - } - - /** - * {@inheritdoc} - */ - public function load(ObjectManager $manager) - { - foreach ($this->container->getParameter('wallabag_core.default_internal_settings') as $setting) { - $newSetting = new Setting(); - $newSetting->setName($setting['name']); - $newSetting->setValue($setting['value']); - $newSetting->setSection($setting['section']); - $manager->persist($newSetting); - } - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 29; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php deleted file mode 100644 index 866f55a4..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php +++ /dev/null @@ -1,34 +0,0 @@ -getReference('admin-user')); - $credential->setHost('example.com'); - $credential->setUsername('foo'); - $credential->setPassword('bar'); - - $manager->persist($credential); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 50; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php deleted file mode 100644 index 0ecfd18b..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php +++ /dev/null @@ -1,55 +0,0 @@ -setLabel('foo bar'); - - $manager->persist($tag1); - - $this->addReference('foo-bar-tag', $tag1); - - $tag2 = new Tag(); - $tag2->setLabel('bar'); - - $manager->persist($tag2); - - $this->addReference('bar-tag', $tag2); - - $tag3 = new Tag(); - $tag3->setLabel('baz'); - - $manager->persist($tag3); - - $this->addReference('baz-tag', $tag3); - - $tag4 = new Tag(); - $tag4->setLabel('foo'); - - $manager->persist($tag4); - - $this->addReference('foo-tag', $tag4); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 25; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php deleted file mode 100644 index 55abd63c..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTaggingRuleData.php +++ /dev/null @@ -1,56 +0,0 @@ -setRule('content matches "spurs"'); - $tr1->setTags(['sport']); - $tr1->setConfig($this->getReference('admin-config')); - - $manager->persist($tr1); - - $tr2 = new TaggingRule(); - $tr2->setRule('content matches "basket"'); - $tr2->setTags(['sport']); - $tr2->setConfig($this->getReference('admin-config')); - - $manager->persist($tr2); - - $tr3 = new TaggingRule(); - - $tr3->setRule('title matches "wallabag"'); - $tr3->setTags(['wallabag']); - $tr3->setConfig($this->getReference('admin-config')); - - $manager->persist($tr3); - - $tr4 = new TaggingRule(); - $tr4->setRule('content notmatches "basket"'); - $tr4->setTags(['foot']); - $tr4->setConfig($this->getReference('admin-config')); - - $manager->persist($tr4); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 40; - } -} diff --git a/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php new file mode 100644 index 00000000..fd129829 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php @@ -0,0 +1,39 @@ +container = $container; + } + + /** + * {@inheritdoc} + */ + public function load(ObjectManager $manager) + { + foreach ($this->container->getParameter('wallabag_core.default_internal_settings') as $setting) { + $newSetting = new Setting(); + $newSetting->setName($setting['name']); + $newSetting->setValue($setting['value']); + $newSetting->setSection($setting['section']); + $manager->persist($newSetting); + } + + $manager->flush(); + } +} diff --git a/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php new file mode 100644 index 00000000..c73173e8 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php @@ -0,0 +1,37 @@ +getReference('admin-user')); + $credential->setHost('example.com'); + $credential->setUsername('foo'); + $credential->setPassword('bar'); + + $manager->persist($credential); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + UserFixtures::class, + ]; + } +} diff --git a/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php new file mode 100644 index 00000000..803ad778 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php @@ -0,0 +1,47 @@ +setLabel('foo bar'); + + $manager->persist($tag1); + + $this->addReference('foo-bar-tag', $tag1); + + $tag2 = new Tag(); + $tag2->setLabel('bar'); + + $manager->persist($tag2); + + $this->addReference('bar-tag', $tag2); + + $tag3 = new Tag(); + $tag3->setLabel('baz'); + + $manager->persist($tag3); + + $this->addReference('baz-tag', $tag3); + + $tag4 = new Tag(); + $tag4->setLabel('foo'); + + $manager->persist($tag4); + + $this->addReference('foo-tag', $tag4); + + $manager->flush(); + } +} diff --git a/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php new file mode 100644 index 00000000..78ff314a --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/TaggingRuleFixtures.php @@ -0,0 +1,58 @@ +setRule('content matches "spurs"'); + $tr1->setTags(['sport']); + $tr1->setConfig($this->getReference('admin-config')); + + $manager->persist($tr1); + + $tr2 = new TaggingRule(); + $tr2->setRule('content matches "basket"'); + $tr2->setTags(['sport']); + $tr2->setConfig($this->getReference('admin-config')); + + $manager->persist($tr2); + + $tr3 = new TaggingRule(); + + $tr3->setRule('title matches "wallabag"'); + $tr3->setTags(['wallabag']); + $tr3->setConfig($this->getReference('admin-config')); + + $manager->persist($tr3); + + $tr4 = new TaggingRule(); + $tr4->setRule('content notmatches "basket"'); + $tr4->setTags(['foot']); + $tr4->setConfig($this->getReference('admin-config')); + + $manager->persist($tr4); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + ConfigFixtures::class, + ]; + } +} diff --git a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php b/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php deleted file mode 100644 index 26dbda3b..00000000 --- a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php +++ /dev/null @@ -1,61 +0,0 @@ -setName('Big boss'); - $userAdmin->setEmail('bigboss@wallabag.org'); - $userAdmin->setUsername('admin'); - $userAdmin->setPlainPassword('mypassword'); - $userAdmin->setEnabled(true); - $userAdmin->addRole('ROLE_SUPER_ADMIN'); - - $manager->persist($userAdmin); - - $this->addReference('admin-user', $userAdmin); - - $bobUser = new User(); - $bobUser->setName('Bobby'); - $bobUser->setEmail('bobby@wallabag.org'); - $bobUser->setUsername('bob'); - $bobUser->setPlainPassword('mypassword'); - $bobUser->setEnabled(true); - - $manager->persist($bobUser); - - $this->addReference('bob-user', $bobUser); - - $emptyUser = new User(); - $emptyUser->setName('Empty'); - $emptyUser->setEmail('empty@wallabag.org'); - $emptyUser->setUsername('empty'); - $emptyUser->setPlainPassword('mypassword'); - $emptyUser->setEnabled(true); - - $manager->persist($emptyUser); - - $this->addReference('empty-user', $emptyUser); - - $manager->flush(); - } - - /** - * {@inheritdoc} - */ - public function getOrder() - { - return 10; - } -} diff --git a/src/Wallabag/UserBundle/DataFixtures/UserFixtures.php b/src/Wallabag/UserBundle/DataFixtures/UserFixtures.php new file mode 100644 index 00000000..1e375e09 --- /dev/null +++ b/src/Wallabag/UserBundle/DataFixtures/UserFixtures.php @@ -0,0 +1,52 @@ +setName('Big boss'); + $userAdmin->setEmail('bigboss@wallabag.org'); + $userAdmin->setUsername('admin'); + $userAdmin->setPlainPassword('mypassword'); + $userAdmin->setEnabled(true); + $userAdmin->addRole('ROLE_SUPER_ADMIN'); + + $manager->persist($userAdmin); + + $this->addReference('admin-user', $userAdmin); + + $bobUser = new User(); + $bobUser->setName('Bobby'); + $bobUser->setEmail('bobby@wallabag.org'); + $bobUser->setUsername('bob'); + $bobUser->setPlainPassword('mypassword'); + $bobUser->setEnabled(true); + + $manager->persist($bobUser); + + $this->addReference('bob-user', $bobUser); + + $emptyUser = new User(); + $emptyUser->setName('Empty'); + $emptyUser->setEmail('empty@wallabag.org'); + $emptyUser->setUsername('empty'); + $emptyUser->setPlainPassword('mypassword'); + $emptyUser->setEnabled(true); + + $manager->persist($emptyUser); + + $this->addReference('empty-user', $emptyUser); + + $manager->flush(); + } +} -- cgit v1.2.3 From 1b6b77f02956a767fb3fa9825a7b97b4879f7d42 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 20:02:15 +0100 Subject: Remove custom Postgres class Because PG > 10 is now supported by DBAL >= 2.6.0 --- app/config/config.yml | 1 - app/config/config_test.yml | 1 - app/config/parameters.yml.dist | 2 -- app/config/parameters_test.yml | 1 - app/config/tests/parameters_test.mysql.yml | 1 - app/config/tests/parameters_test.pgsql.yml | 1 - app/config/tests/parameters_test.sqlite.yml | 1 - .../DBAL/Driver/CustomPostgreSQLDriver.php | 25 -------------- .../DBAL/Schema/CustomPostgreSqlSchemaManager.php | 38 ---------------------- 9 files changed, 71 deletions(-) delete mode 100644 src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php delete mode 100644 src/Wallabag/CoreBundle/Doctrine/DBAL/Schema/CustomPostgreSqlSchemaManager.php diff --git a/app/config/config.yml b/app/config/config.yml index 092f3ec0..ee0f0a38 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -46,7 +46,6 @@ twig: doctrine: dbal: driver: "%database_driver%" - driver_class: "%database_driver_class%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" diff --git a/app/config/config_test.yml b/app/config/config_test.yml index 11e0feb7..216f8431 100644 --- a/app/config/config_test.yml +++ b/app/config/config_test.yml @@ -24,7 +24,6 @@ swiftmailer: doctrine: dbal: driver: "%test_database_driver%" - driver_class: "%test_database_driver_class%" host: "%test_database_host%" port: "%test_database_port%" dbname: "%test_database_name%" diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index d21f20e0..13e2584f 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -11,8 +11,6 @@ parameters: # database_password: %env.database_password% database_driver: pdo_mysql - database_driver_class: ~ - # database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver database_host: 127.0.0.1 database_port: ~ database_name: wallabag diff --git a/app/config/parameters_test.yml b/app/config/parameters_test.yml index 64e51976..257d2ace 100644 --- a/app/config/parameters_test.yml +++ b/app/config/parameters_test.yml @@ -8,4 +8,3 @@ parameters: test_database_path: "%env(TEST_DATABASE_PATH)%" env(TEST_DATABASE_PATH): "%kernel.project_dir%/data/db/wallabag_test.sqlite" test_database_charset: utf8 - test_database_driver_class: ~ diff --git a/app/config/tests/parameters_test.mysql.yml b/app/config/tests/parameters_test.mysql.yml index 0b7b82eb..36b227fb 100644 --- a/app/config/tests/parameters_test.mysql.yml +++ b/app/config/tests/parameters_test.mysql.yml @@ -1,6 +1,5 @@ parameters: test_database_driver: pdo_mysql - test_database_driver_class: ~ test_database_host: localhost test_database_port: 3306 test_database_name: wallabag_test diff --git a/app/config/tests/parameters_test.pgsql.yml b/app/config/tests/parameters_test.pgsql.yml index ea249324..60f51df6 100644 --- a/app/config/tests/parameters_test.pgsql.yml +++ b/app/config/tests/parameters_test.pgsql.yml @@ -1,6 +1,5 @@ parameters: test_database_driver: pdo_pgsql - test_database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver test_database_host: localhost test_database_port: test_database_name: wallabag_test diff --git a/app/config/tests/parameters_test.sqlite.yml b/app/config/tests/parameters_test.sqlite.yml index 64cd984b..2b92d579 100644 --- a/app/config/tests/parameters_test.sqlite.yml +++ b/app/config/tests/parameters_test.sqlite.yml @@ -1,6 +1,5 @@ parameters: test_database_driver: pdo_sqlite - test_database_driver_class: ~ test_database_host: localhost test_database_port: test_database_name: ~ diff --git a/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php b/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php deleted file mode 100644 index eb5b203f..00000000 --- a/src/Wallabag/CoreBundle/Doctrine/DBAL/Driver/CustomPostgreSQLDriver.php +++ /dev/null @@ -1,25 +0,0 @@ -_platform->quoteIdentifier($sequenceName); - - // the `method_exists` is only to avoid test to fail: - // DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticConnection doesn't support the `getServerVersion` - if (method_exists($this->_conn->getWrappedConnection(), 'getServerVersion') && (float) ($this->_conn->getWrappedConnection()->getServerVersion()) >= 10) { - $query = "SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = 'public' AND sequencename = " . $this->_conn->quote($sequenceName); - } - - $data = $this->_conn->fetchAll($query); - - return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']); - } -} -- cgit v1.2.3 From 8f2038e5b15c2d7342ed18381531e5eb95e86d46 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 22:22:49 +0100 Subject: Fix tests --- composer.json | 41 ++++++----- .../Controller/AnnotationControllerTest.php | 3 +- .../Controller/EntryRestControllerTest.php | 84 +++++++++++----------- tests/Wallabag/ApiBundle/WallabagApiTestCase.php | 19 +++++ .../ImportBundle/Command/ImportCommandTest.php | 4 +- 5 files changed, 83 insertions(+), 68 deletions(-) diff --git a/composer.json b/composer.json index 8b31085b..4f609567 100644 --- a/composer.json +++ b/composer.json @@ -44,15 +44,15 @@ "ext-tokenizer": "*", "ext-pdo": "*", "symfony/symfony": "3.4.*", - "doctrine/orm": "^2.5.12", - "doctrine/doctrine-bundle": "^1.8.0", - "doctrine/doctrine-cache-bundle": "^1.3.2", - "twig/extensions": "^1.5.1", - "symfony/swiftmailer-bundle": "^3.2.3", - "symfony/monolog-bundle": "^3.1.2", - "sensio/distribution-bundle": "^5.0.21", - "sensio/framework-extra-bundle": "^5.2.1", - "incenteev/composer-parameter-handler": "^2.1.2", + "doctrine/orm": "^2.6", + "doctrine/doctrine-bundle": "^1.9", + "doctrine/doctrine-cache-bundle": "^1.3", + "twig/extensions": "^1.5", + "symfony/swiftmailer-bundle": "^3.2", + "symfony/monolog-bundle": "^3.1", + "sensio/distribution-bundle": "^5.0", + "sensio/framework-extra-bundle": "^5.2", + "incenteev/composer-parameter-handler": "^2.1", "nelmio/cors-bundle": "~1.5", "friendsofsymfony/rest-bundle": "~2.1", "jms/serializer-bundle": "~2.2", @@ -62,27 +62,26 @@ "simplepie/simplepie": "~1.5", "willdurand/hateoas-bundle": "~1.3", "liip/theme-bundle": "^1.4.6", - "lexik/form-filter-bundle": "^5.0.4", + "lexik/form-filter-bundle": "^5.0", "j0k3r/graby": "^1.0", "friendsofsymfony/user-bundle": "2.0.*", - "friendsofsymfony/oauth-server-bundle": "^1.5.2", + "friendsofsymfony/oauth-server-bundle": "^1.5", "stof/doctrine-extensions-bundle": "^1.2", - "scheb/two-factor-bundle": "^2.14.0", + "scheb/two-factor-bundle": "^2.14", "grandt/phpepub": "dev-master", - "wallabag/php-mobi": "~1.0.0", + "wallabag/php-mobi": "~1.0", "kphoen/rulerz-bundle": "~0.13", "guzzlehttp/guzzle": "^5.3.1", "doctrine/doctrine-migrations-bundle": "^1.3", - "paragonie/random_compat": "^2.0.11", "craue/config-bundle": "~2.0", "mnapoli/piwik-twig-extension": "^1.0", "ocramius/proxy-manager": "^1.0.2", - "white-october/pagerfanta-bundle": "^1.1.0", + "white-october/pagerfanta-bundle": "^1.1", "php-amqplib/rabbitmq-bundle": "^1.14", "predis/predis": "v1.1.x-dev", "javibravo/simpleue": "^2.0", - "symfony/dom-crawler": "^3.3.13", - "friendsofsymfony/jsrouting-bundle": "^2.2.1", + "symfony/dom-crawler": "^3.4", + "friendsofsymfony/jsrouting-bundle": "^2.2", "bdunogier/guzzle-site-authenticator": "^1.0.0@dev", "defuse/php-encryption": "^2.1", "html2text/html2text": "^4.1" @@ -90,10 +89,10 @@ "require-dev": { "doctrine/doctrine-fixtures-bundle": "~3.0", "sensio/generator-bundle": "^3.0", - "symfony/phpunit-bridge": "3.4.x-dev", - "friendsofphp/php-cs-fixer": "~2.0", - "m6web/redis-mock": "^2.0", - "dama/doctrine-test-bundle": "^4.0" + "symfony/phpunit-bridge": "^3.4", + "friendsofphp/php-cs-fixer": "~2.13", + "m6web/redis-mock": "^4.1", + "dama/doctrine-test-bundle": "^5.0" }, "scripts": { "post-cmd": [ diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index 96474468..537283f2 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php @@ -100,8 +100,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase $this->assertSame('my quote', $content['quote']); /** @var Annotation $annotation */ - $annotation = $this->client->getContainer() - ->get('doctrine.orm.entity_manager') + $annotation = $em ->getRepository('WallabagAnnotationBundle:Annotation') ->findLastAnnotationByPageId($entry->getId(), 1); diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 6b26376d..176da3cd 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -15,7 +15,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isArchived' => false]); + ->findOneBy(['user' => $this->getUserId(), 'isArchived' => false]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -41,7 +41,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'url' => 'http://0.0.0.0/entry2']); + ->findOneBy(['user' => $this->getUserId(), 'url' => 'http://0.0.0.0/entry2']); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -60,7 +60,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isArchived' => false]); + ->findOneBy(['user' => $this->getUserId(), 'isArchived' => false]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -108,7 +108,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 2, 'isArchived' => false]); + ->findOneBy(['user' => $this->getUserId('bob'), 'isArchived' => false]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -185,7 +185,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -394,7 +394,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1, ['id' => 'asc']); + ->findOneByUser($this->getUserId(), ['id' => 'asc']); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -440,7 +440,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertNull($content['starred_at']); $this->assertNull($content['archived_at']); $this->assertSame('New title for my article', $content['title']); - $this->assertSame(1, $content['user_id']); + $this->assertSame($this->getUserId(), $content['user_id']); $this->assertCount(2, $content['tags']); $this->assertNull($content['origin_url']); $this->assertSame('my content', $content['content']); @@ -455,7 +455,7 @@ 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 = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl('https://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')); @@ -535,7 +535,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertSame(1, $content['is_starred']); $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['archived_at']))->getTimestamp()); - $this->assertSame(1, $content['user_id']); + $this->assertSame($this->getUserId(), $content['user_id']); } public function testPostArchivedAndStarredEntryWithoutQuotes() @@ -584,7 +584,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -611,7 +611,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertSame($entry->getUrl(), $content['url']); $this->assertSame('New awesome title', $content['title']); $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag'); - $this->assertSame(1, $content['user_id']); + $this->assertSame($this->getUserId(), $content['user_id']); $this->assertSame('de_AT', $content['language']); $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); $this->assertContains('sponge', $content['published_by']); @@ -626,7 +626,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -660,7 +660,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -691,7 +691,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -723,7 +723,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -768,7 +768,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -833,7 +833,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isArchived' => true]); + ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -855,7 +855,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isStarred' => true]); + ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -877,7 +877,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isArchived' => true]); + ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -903,7 +903,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneBy(['user' => 1, 'isStarred' => true]); + ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -920,32 +920,27 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); } - public function dataForEntriesExistWithUrl() + public function testGetEntriesExistsWithReturnId() { - return [ - 'with_id' => [ - 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1', - 'expectedValue' => 2, - ], - 'without_id' => [ - 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2', - 'expectedValue' => true, - ], - ]; + $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1'); + + $this->assertSame(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + // it returns a database id, we don't know it, so we only check it's greater than the lowest possible value + $this->assertGreaterThan(1, $content['exists']); } - /** - * @dataProvider dataForEntriesExistWithUrl - */ - public function testGetEntriesExists($url, $expectedValue) + public function testGetEntriesExistsWithoutReturnId() { - $this->client->request('GET', $url); + $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2'); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); - $this->assertSame($expectedValue, $content['exists']); + $this->assertSame(true, $content['exists']); } public function testGetEntriesExistsWithManyUrls() @@ -960,7 +955,8 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); - $this->assertSame(2, $content[$url1]); + // it returns a database id, we don't know it, so we only check it's greater than the lowest possible value + $this->assertGreaterThan(1, $content[$url1]); $this->assertNull($content[$url2]); } @@ -1002,7 +998,7 @@ class EntryRestControllerTest extends WallabagApiTestCase { $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId()); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -1038,7 +1034,7 @@ class EntryRestControllerTest extends WallabagApiTestCase { $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId()); $tags = $entry->getTags(); @@ -1062,7 +1058,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId()); $tags = $entry->getTags(); $this->assertCount(4, $tags); @@ -1082,7 +1078,7 @@ class EntryRestControllerTest extends WallabagApiTestCase public function testDeleteEntriesTagsListAction() { $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); - $entry = new Entry($em->getReference(User::class, 1)); + $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl('http://0.0.0.0/test-entry'); $entry->addTag((new Tag())->setLabel('foo-tag')); $entry->addTag((new Tag())->setLabel('bar-tag')); @@ -1150,7 +1146,7 @@ class EntryRestControllerTest extends WallabagApiTestCase public function testDeleteEntriesListAction() { $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); - $em->persist((new Entry($em->getReference(User::class, 1)))->setUrl('http://0.0.0.0/test-entry1')); + $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl('http://0.0.0.0/test-entry1')); $em->flush(); $em->clear(); @@ -1208,7 +1204,7 @@ class EntryRestControllerTest extends WallabagApiTestCase public function testRePostEntryAndReUsePublishedAt() { $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); - $entry = new Entry($em->getReference(User::class, 1)); + $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »'); $entry->setContent('hihi'); $entry->setUrl('https://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html'); diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index 0c52aea0..a0f2f889 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -48,4 +48,23 @@ abstract class WallabagApiTestCase extends WebTestCase return $client; } + + /** + * Return the ID for the user admin. + * Used because on heavy testing we don't want to re-create the database on each run. + * Which means "admin" user won't have id 1 all the time. + * + * @param string $username + * + * @return int + */ + public function getUserId($username = 'admin') + { + return $this->client + ->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagUserBundle:User') + ->findOneByUserName($username) + ->getId(); + } } diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php index f95320a4..8e1c528d 100644 --- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php @@ -84,6 +84,8 @@ class ImportCommandTest extends WallabagCoreTestCase public function testRunImportCommandWithUserId() { + $this->logInAs('admin'); + $application = new Application($this->getClient()->getKernel()); $application->add(new ImportCommand()); @@ -92,7 +94,7 @@ class ImportCommandTest extends WallabagCoreTestCase $tester = new CommandTester($command); $tester->execute([ 'command' => $command->getName(), - 'username' => 1, + 'username' => $this->getLoggedInUserId(), 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', '--useUserId' => true, '--importer' => 'v2', -- cgit v1.2.3 From b13b2ef052f3c21f17ab2a4f3f410049e3c79c83 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Nov 2018 22:46:44 +0100 Subject: CS --- src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php | 1 - src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php | 1 - tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 2 +- tests/Wallabag/ApiBundle/WallabagApiTestCase.php | 4 ++-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php index fd129829..cc7d1f59 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/SettingFixtures.php @@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\DataFixtures; use Craue\ConfigBundle\Entity\Setting; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php index 803ad778..d78dd0b8 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/TagFixtures.php @@ -3,7 +3,6 @@ namespace Wallabag\CoreBundle\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use Wallabag\CoreBundle\Entity\Tag; diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 176da3cd..3696f8f9 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -940,7 +940,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $content = json_decode($this->client->getResponse()->getContent(), true); - $this->assertSame(true, $content['exists']); + $this->assertTrue($content['exists']); } public function testGetEntriesExistsWithManyUrls() diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index a0f2f889..fd2e113e 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -54,11 +54,11 @@ abstract class WallabagApiTestCase extends WebTestCase * Used because on heavy testing we don't want to re-create the database on each run. * Which means "admin" user won't have id 1 all the time. * - * @param string $username + * @param string $username * * @return int */ - public function getUserId($username = 'admin') + protected function getUserId($username = 'admin') { return $this->client ->getContainer() -- cgit v1.2.3 From f168642b5041ddd97973f15cf8da8e69ea3db5f2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 27 Nov 2018 10:29:11 +0100 Subject: Force PHPUnit Looks like "dama/doctrine-test-bundle" isn't compatible with PHPUnit 5.7 (required automatically by PHPUnit Bridge) --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60721f61..9d7fd3a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,6 @@ services: - rabbitmq - redis -# used for HHVM -addons: - apt: - packages: - - tidy - # cache vendor dirs cache: apt: true @@ -23,6 +17,7 @@ cache: php: - 7.1 - 7.2 + - 7.3 - nightly node_js: @@ -40,6 +35,7 @@ matrix: env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite allow_failures: - php: nightly + - php: 7.3 # exclude v1 branches branches: @@ -70,7 +66,7 @@ script: - make fixtures - - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then ./bin/simple-phpunit -v ; fi; + - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then SYMFONY_PHPUNIT_VERSION=6.5 ./bin/simple-phpunit -v ; 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; -- cgit v1.2.3 From 9a8a1bdfdbc87047bffb457370e04ef58a24495c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 27 Nov 2018 11:38:28 +0100 Subject: Use our own fork for CraueConfigBundle Mostly to fix utf8mb4 issue --- composer.json | 7 ++++++- tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4f609567..405b1188 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "kphoen/rulerz-bundle": "~0.13", "guzzlehttp/guzzle": "^5.3.1", "doctrine/doctrine-migrations-bundle": "^1.3", - "craue/config-bundle": "~2.0", + "craue/config-bundle": "dev-utf8mb4", "mnapoli/piwik-twig-extension": "^1.0", "ocramius/proxy-manager": "^1.0.2", "white-october/pagerfanta-bundle": "^1.1", @@ -148,6 +148,11 @@ "type": "vcs", "url": "https://github.com/Daniel-KM/PHPePub", "comment": "The most up-to-date PHPePub as of now" + }, + { + "type": "vcs", + "url": "https://github.com/wallabag/CraueConfigBundle", + "comment": "To handle utf8mb4 field size" } ] } diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index bd351b18..08685408 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php @@ -62,6 +62,7 @@ class InstallCommandTest extends WallabagCoreTestCase $databasePath = getenv('TEST_DATABASE_PATH'); // Remove variable environnement putenv('TEST_DATABASE_PATH'); + if ($databasePath && file_exists($databasePath)) { unlink($databasePath); } else { -- cgit v1.2.3 From 877787e5fe6a6545105616968939949b4db81347 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 28 Nov 2018 20:26:18 +0100 Subject: Fix utf8mb4 on vendor tables When creating the schema for test these tables use default length for string: 255. Which fail when using utf8mb4. > Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes Also move the `setKeepStaticConnections` in before and after class to avoid: > SAVEPOINT DOCTRINE2_SAVEPOINT_2 does not exist See https://github.com/dmaicher/doctrine-test-bundle#troubleshooting --- app/DoctrineMigrations/Version20180405182455.php | 21 +--------- app/DoctrineMigrations/Version20181128203230.php | 45 ++++++++++++++++++++++ src/Wallabag/ApiBundle/Entity/AccessToken.php | 16 ++++++++ src/Wallabag/ApiBundle/Entity/AuthCode.php | 16 ++++++++ src/Wallabag/ApiBundle/Entity/RefreshToken.php | 16 ++++++++ .../CoreBundle/Command/InstallCommandTest.php | 17 +++++--- 6 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 app/DoctrineMigrations/Version20181128203230.php diff --git a/app/DoctrineMigrations/Version20180405182455.php b/app/DoctrineMigrations/Version20180405182455.php index 71879c0e..50fe97c7 100755 --- a/app/DoctrineMigrations/Version20180405182455.php +++ b/app/DoctrineMigrations/Version20180405182455.php @@ -2,26 +2,14 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Wallabag\CoreBundle\Doctrine\WallabagMigration; /** * Add archived_at column and set its value to updated_at for is_archived entries. */ -class Version20180405182455 extends AbstractMigration implements ContainerAwareInterface +class Version20180405182455 extends WallabagMigration { - /** - * @var ContainerInterface - */ - private $container; - - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - /** * @param Schema $schema */ @@ -60,9 +48,4 @@ class Version20180405182455 extends AbstractMigration implements ContainerAwareI $entryTable->dropColumn('archived_at'); } - - private function getTable($tableName) - { - return $this->container->getParameter('database_table_prefix') . $tableName; - } } diff --git a/app/DoctrineMigrations/Version20181128203230.php b/app/DoctrineMigrations/Version20181128203230.php new file mode 100644 index 00000000..d1b09fc7 --- /dev/null +++ b/app/DoctrineMigrations/Version20181128203230.php @@ -0,0 +1,45 @@ +skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); + + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(191)'); + } + + public function down(Schema $schema) + { + $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); + + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(255)'); + } +} diff --git a/src/Wallabag/ApiBundle/Entity/AccessToken.php b/src/Wallabag/ApiBundle/Entity/AccessToken.php index c09a0c80..5e4099dd 100644 --- a/src/Wallabag/ApiBundle/Entity/AccessToken.php +++ b/src/Wallabag/ApiBundle/Entity/AccessToken.php @@ -8,6 +8,22 @@ use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken; /** * @ORM\Table("oauth2_access_tokens") * @ORM\Entity + * @ORM\AttributeOverrides({ + * @ORM\AttributeOverride(name="token", + * column=@ORM\Column( + * name = "token", + * type = "string", + * length = 191 + * ) + * ), + * @ORM\AttributeOverride(name="scope", + * column=@ORM\Column( + * name = "scope", + * type = "string", + * length = 191 + * ) + * ) + * }) */ class AccessToken extends BaseAccessToken { diff --git a/src/Wallabag/ApiBundle/Entity/AuthCode.php b/src/Wallabag/ApiBundle/Entity/AuthCode.php index 4d4b09fe..5fa205ac 100644 --- a/src/Wallabag/ApiBundle/Entity/AuthCode.php +++ b/src/Wallabag/ApiBundle/Entity/AuthCode.php @@ -8,6 +8,22 @@ use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode; /** * @ORM\Table("oauth2_auth_codes") * @ORM\Entity + * @ORM\AttributeOverrides({ + * @ORM\AttributeOverride(name="token", + * column=@ORM\Column( + * name = "token", + * type = "string", + * length = 191 + * ) + * ), + * @ORM\AttributeOverride(name="scope", + * column=@ORM\Column( + * name = "scope", + * type = "string", + * length = 191 + * ) + * ) + * }) */ class AuthCode extends BaseAuthCode { diff --git a/src/Wallabag/ApiBundle/Entity/RefreshToken.php b/src/Wallabag/ApiBundle/Entity/RefreshToken.php index 822a02d8..dd8e9c63 100644 --- a/src/Wallabag/ApiBundle/Entity/RefreshToken.php +++ b/src/Wallabag/ApiBundle/Entity/RefreshToken.php @@ -8,6 +8,22 @@ use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken; /** * @ORM\Table("oauth2_refresh_tokens") * @ORM\Entity + * @ORM\AttributeOverrides({ + * @ORM\AttributeOverride(name="token", + * column=@ORM\Column( + * name = "token", + * type = "string", + * length = 191 + * ) + * ), + * @ORM\AttributeOverride(name="scope", + * column=@ORM\Column( + * name = "scope", + * type = "string", + * length = 191 + * ) + * ) + * }) */ class RefreshToken extends BaseRefreshToken { diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index 08685408..d8928451 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php @@ -18,6 +18,18 @@ use Wallabag\CoreBundle\Command\InstallCommand; class InstallCommandTest extends WallabagCoreTestCase { + public static function setUpBeforeClass() + { + // disable doctrine-test-bundle + StaticDriver::setKeepStaticConnections(false); + } + + public static function tearDownAfterClass() + { + // enable doctrine-test-bundle + StaticDriver::setKeepStaticConnections(true); + } + public function setUp() { parent::setUp(); @@ -51,9 +63,6 @@ class InstallCommandTest extends WallabagCoreTestCase parent::setUp(); } - // disable doctrine-test-bundle - StaticDriver::setKeepStaticConnections(false); - $this->resetDatabase($this->getClient()); } @@ -72,8 +81,6 @@ class InstallCommandTest extends WallabagCoreTestCase $this->resetDatabase($client); } - // enable doctrine-test-bundle - StaticDriver::setKeepStaticConnections(true); parent::tearDown(); } -- cgit v1.2.3