Merge pull request #3758 from wallabag/dropping-php5

Dropping PHP < 7.1
This commit is contained in:
Jérémy Benoist 2018-11-29 16:41:23 +01:00 committed by GitHub
commit 39502b4748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 328 additions and 340 deletions

View file

@ -4,12 +4,6 @@ services:
- rabbitmq
- redis
# used for HHVM
addons:
apt:
packages:
- tidy
# cache vendor dirs
cache:
apt: true
@ -21,10 +15,9 @@ cache:
- $HOME/.yarn-cache
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly
node_js:
@ -38,10 +31,11 @@ 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
- php: 7.3
# exclude v1 branches
branches:
@ -63,14 +57,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,11 +64,9 @@ 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 [[ $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;

View file

@ -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

View file

@ -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

View file

@ -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 <nicolas@loeuillet.org>
Copyright © 2013-current Nicolas Lœuillet <nicolas@loeuillet.org>
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.

View file

@ -1,6 +1,7 @@
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
@ -46,18 +47,26 @@ class AppKernel extends Kernel
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
if ('test' === $this->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);
});
}
}

View file

@ -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;
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Wallabag\CoreBundle\Doctrine\WallabagMigration;
/**
* Fix varchar field from vendor to work with utf8mb4.
*/
class Version20181128203230 extends WallabagMigration
{
/**
* @param Schema $schema
*/
public function up(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(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)');
}
}

View file

@ -1,13 +0,0 @@
<?php
use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
/**
* @var ClassLoader
*/
$loader = require __DIR__ . '/../vendor/autoload.php';
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
return $loader;

View file

@ -46,7 +46,6 @@ twig:
doctrine:
dbal:
driver: "%database_driver%"
driver_class: "%database_driver_class%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"

View file

@ -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%"

View file

@ -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

View file

@ -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: ~

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,5 @@
parameters:
test_database_driver: pdo_sqlite
test_database_driver_class: ~
test_database_host: localhost
test_database_port:
test_database_name: ~

View file

@ -6,19 +6,17 @@ use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
set_time_limit(0);
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../app/autoload.php';
require __DIR__.'/../vendor/autoload.php';
$input = new ArgvInput();
$env = $input->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();

View file

@ -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": "*",
@ -44,45 +44,44 @@
"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": "^2.6.7",
"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",
"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",
"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",
"grandt/phpepub": "^4.0.7",
"wallabag/php-mobi": "~1.0.0",
"scheb/two-factor-bundle": "^2.14",
"grandt/phpepub": "dev-master",
"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",
"craue/config-bundle": "dev-utf8mb4",
"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": "^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",
"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": [
@ -122,18 +121,38 @@
}
},
"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": "5.6.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"
},
{
"type": "vcs",
"url": "https://github.com/wallabag/CraueConfigBundle",
"comment": "To handle utf8mb4 field size"
}
]
}

View file

@ -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"
>
<testsuites>
@ -15,7 +15,7 @@
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>

View file

@ -1,13 +1,15 @@
<?php
namespace Wallabag\AnnotationBundle\DataFixtures\ORM;
namespace Wallabag\AnnotationBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\DataFixtures\EntryFixtures;
use Wallabag\UserBundle\DataFixtures\UserFixtures;
class LoadAnnotationData extends AbstractFixture implements OrderedFixtureInterface
class AnnotationFixtures extends Fixture implements DependentFixtureInterface
{
/**
* {@inheritdoc}
@ -38,8 +40,11 @@ class LoadAnnotationData extends AbstractFixture implements OrderedFixtureInterf
/**
* {@inheritdoc}
*/
public function getOrder()
public function getDependencies()
{
return 35;
return [
EntryFixtures::class,
UserFixtures::class,
];
}
}

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -1,13 +1,14 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\DataFixtures\UserFixtures;
class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
class ConfigFixtures extends Fixture implements DependentFixtureInterface
{
/**
* {@inheritdoc}
@ -60,8 +61,10 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
/**
* {@inheritdoc}
*/
public function getOrder()
public function getDependencies()
{
return 20;
return [
UserFixtures::class,
];
}
}

View file

@ -1,13 +1,14 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\UserBundle\DataFixtures\UserFixtures;
class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
class EntryFixtures extends Fixture implements DependentFixtureInterface
{
/**
* {@inheritdoc}
@ -112,8 +113,11 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
/**
* {@inheritdoc}
*/
public function getOrder()
public function getDependencies()
{
return 30;
return [
UserFixtures::class,
TagFixtures::class,
];
}
}

View file

@ -1,15 +1,14 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Craue\ConfigBundle\Entity\Setting;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
class SettingFixtures extends Fixture implements ContainerAwareInterface
{
/**
* @var ContainerInterface
@ -36,12 +35,4 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
$manager->flush();
}
/**
* {@inheritdoc}
*/
public function getOrder()
{
return 29;
}
}

View file

@ -1,13 +1,14 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\UserBundle\DataFixtures\UserFixtures;
class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureInterface
class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface
{
/**
* {@inheritdoc}
@ -27,8 +28,10 @@ class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureIn
/**
* {@inheritdoc}
*/
public function getOrder()
public function getDependencies()
{
return 50;
return [
UserFixtures::class,
];
}
}

View file

@ -1,13 +1,12 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\CoreBundle\Entity\Tag;
class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
class TagFixtures extends Fixture
{
/**
* {@inheritdoc}
@ -44,12 +43,4 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
$manager->flush();
}
/**
* {@inheritdoc}
*/
public function getOrder()
{
return 25;
}
}

View file

@ -1,13 +1,13 @@
<?php
namespace Wallabag\CoreBundle\DataFixtures\ORM;
namespace Wallabag\CoreBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\CoreBundle\Entity\TaggingRule;
class LoadTaggingRuleData extends AbstractFixture implements OrderedFixtureInterface
class TaggingRuleFixtures extends Fixture implements DependentFixtureInterface
{
/**
* {@inheritdoc}
@ -49,8 +49,10 @@ class LoadTaggingRuleData extends AbstractFixture implements OrderedFixtureInter
/**
* {@inheritdoc}
*/
public function getOrder()
public function getDependencies()
{
return 40;
return [
ConfigFixtures::class,
];
}
}

View file

@ -1,25 +0,0 @@
<?php
namespace Wallabag\CoreBundle\Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Wallabag\CoreBundle\Doctrine\DBAL\Schema\CustomPostgreSqlSchemaManager;
/**
* This custom driver allow to use a different schema manager
* So we can fix the PostgreSQL 10 problem.
*
* @see https://github.com/wallabag/wallabag/issues/3479
* @see https://github.com/doctrine/dbal/issues/2868
*/
class CustomPostgreSQLDriver extends Driver
{
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn)
{
return new CustomPostgreSqlSchemaManager($conn);
}
}

View file

@ -1,38 +0,0 @@
<?php
namespace Wallabag\CoreBundle\Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\Schema\Sequence;
/**
* This custom schema manager fix the PostgreSQL 10 problem.
*
* @see https://github.com/wallabag/wallabag/issues/3479
* @see https://github.com/doctrine/dbal/issues/2868
*/
class CustomPostgreSqlSchemaManager extends PostgreSqlSchemaManager
{
/**
* {@inheritdoc}
*/
protected function _getPortableSequenceDefinition($sequence)
{
$sequenceName = $sequence['relname'];
if ('public' !== $sequence['schemaname']) {
$sequenceName = $sequence['schemaname'] . '.' . $sequence['relname'];
}
$query = 'SELECT min_value, increment_by FROM ' . $this->_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']);
}
}

View file

@ -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;

View file

@ -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;
/**

View file

@ -1,13 +1,12 @@
<?php
namespace Wallabag\UserBundle\DataFixtures\ORM;
namespace Wallabag\UserBundle\DataFixtures;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Wallabag\UserBundle\Entity\User;
class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
class UserFixtures extends Fixture
{
/**
* {@inheritdoc}
@ -50,12 +49,4 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface
$manager->flush();
}
/**
* {@inheritdoc}
*/
public function getOrder()
{
return 10;
}
}

View file

@ -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);

View file

@ -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,
],
];
}
/**
* @dataProvider dataForEntriesExistWithUrl
*/
public function testGetEntriesExists($url, $expectedValue)
{
$this->client->request('GET', $url);
$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);
$this->assertSame($expectedValue, $content['exists']);
// 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']);
}
public function testGetEntriesExistsWithoutReturnId()
{
$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->assertTrue($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');

View file

@ -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
*/
protected function getUserId($username = 'admin')
{
return $this->client
->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagUserBundle:User')
->findOneByUserName($username)
->getId();
}
}

View file

@ -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());
}
@ -62,6 +71,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 {
@ -71,8 +81,6 @@ class InstallCommandTest extends WallabagCoreTestCase
$this->resetDatabase($client);
}
// enable doctrine-test-bundle
StaticDriver::setKeepStaticConnections(true);
parent::tearDown();
}

View file

@ -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',

View file

@ -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

View file

@ -1,10 +1,10 @@
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
@ -12,20 +12,16 @@ use Symfony\Component\Debug\Debug;
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../app/autoload.php';
require __DIR__.'/../vendor/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();