- rabbitmq
- redis
-# used for HHVM
-addons:
- apt:
- packages:
- - tidy
-
# cache vendor dirs
cache:
apt: true
- $HOME/.yarn-cache
php:
- - 5.6
- - 7.0
- 7.1
- 7.2
+ - 7.3
- nightly
node_js:
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:
- 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
- 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;
+++ /dev/null
-# 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
-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
```
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)
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.
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
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();
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', [
]);
}
});
+
+ $loader->load(function (ContainerBuilder $container) {
+ // $container->setParameter('container.autowiring.strict_mode', true);
+ // $container->setParameter('container.dumper.inline_class_loader', true);
+ $container->addObjectResource($this);
+ });
}
}
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
*/
$entryTable->dropColumn('archived_at');
}
-
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix') . $tableName;
- }
}
--- /dev/null
+<?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)');
+ }
+}
+++ /dev/null
-<?php
-
-use Composer\Autoload\ClassLoader;
-use Doctrine\Common\Annotations\AnnotationRegistry;
-
-/**
- * @var ClassLoader
- */
-$loader = require __DIR__ . '/../vendor/autoload.php';
-
-AnnotationRegistry::registerLoader([$loader, 'loadClass']);
-
-return $loader;
doctrine:
dbal:
driver: "%database_driver%"
- driver_class: "%database_driver_class%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
doctrine:
dbal:
driver: "%test_database_driver%"
- driver_class: "%test_database_driver_class%"
host: "%test_database_host%"
port: "%test_database_port%"
dbname: "%test_database_name%"
# 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
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: ~
- "%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
parameters:
test_database_driver: pdo_mysql
- test_database_driver_class: ~
test_database_host: localhost
test_database_port: 3306
test_database_name: wallabag_test
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
parameters:
test_database_driver: pdo_sqlite
- test_database_driver_class: ~
test_database_host: localhost
test_database_port:
test_database_name: ~
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();
"issues": "https://github.com/wallabag/wallabag/issues"
},
"require": {
- "php": ">=5.6.0",
+ "php": ">=7.1.0",
"ext-pcre": "*",
"ext-dom": "*",
"ext-curl": "*",
"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"
"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": [
}
},
"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"
+ }
+ ]
}
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
colors="true"
- bootstrap="app/autoload.php"
+ bootstrap="vendor/autoload.php"
>
<testsuites>
<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>
<?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}
/**
* {@inheritdoc}
*/
- public function getOrder()
+ public function getDependencies()
{
- return 35;
+ return [
+ EntryFixtures::class,
+ UserFixtures::class,
+ ];
}
}
/**
* @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
{
/**
* @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
{
/**
* @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
{
<?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}
/**
* {@inheritdoc}
*/
- public function getOrder()
+ public function getDependencies()
{
- return 20;
+ return [
+ UserFixtures::class,
+ ];
}
}
<?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}
/**
* {@inheritdoc}
*/
- public function getOrder()
+ public function getDependencies()
{
- return 30;
+ return [
+ UserFixtures::class,
+ TagFixtures::class,
+ ];
}
}
<?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
$manager->flush();
}
-
- /**
- * {@inheritdoc}
- */
- public function getOrder()
- {
- return 29;
- }
}
<?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}
/**
* {@inheritdoc}
*/
- public function getOrder()
+ public function getDependencies()
{
- return 50;
+ return [
+ UserFixtures::class,
+ ];
}
}
<?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}
$manager->flush();
}
-
- /**
- * {@inheritdoc}
- */
- public function getOrder()
- {
- return 25;
- }
}
<?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}
/**
* {@inheritdoc}
*/
- public function getOrder()
+ public function getDependencies()
{
- return 40;
+ return [
+ ConfigFixtures::class,
+ ];
}
}
+++ /dev/null
-<?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);
- }
-}
+++ /dev/null
-<?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']);
- }
-}
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;
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;
/**
<?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}
$manager->flush();
}
-
- /**
- * {@inheritdoc}
- */
- public function getOrder()
- {
- return 10;
- }
}
$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);
$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.');
$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.');
$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.');
$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.');
$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.');
$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.');
$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']);
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'));
$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()
$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.');
$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']);
$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.');
$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.');
$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.');
$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.');
$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.');
$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.');
$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.');
$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.');
$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.');
$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->assertTrue($content['exists']);
}
public function testGetEntriesExistsWithManyUrls()
$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]);
}
{
$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.');
{
$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();
$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);
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'));
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();
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');
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();
+ }
}
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();
parent::setUp();
}
- // disable doctrine-test-bundle
- StaticDriver::setKeepStaticConnections(false);
-
$this->resetDatabase($this->getClient());
}
$databasePath = getenv('TEST_DATABASE_PATH');
// Remove variable environnement
putenv('TEST_DATABASE_PATH');
+
if ($databasePath && file_exists($databasePath)) {
unlink($databasePath);
} else {
$this->resetDatabase($client);
}
- // enable doctrine-test-bundle
- StaticDriver::setKeepStaticConnections(true);
parent::tearDown();
}
public function testRunImportCommandWithUserId()
{
+ $this->logInAs('admin');
+
$application = new Application($this->getClient()->getKernel());
$application->add(new ImportCommand());
$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',
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
<?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);
// 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();