mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Merge pull request #1434 from wallabag/travis-db
Add multiple database tests on Travis
This commit is contained in:
commit
917040d4a0
16 changed files with 348 additions and 127 deletions
34
.travis.yml
34
.travis.yml
|
@ -3,6 +3,12 @@ language: php
|
|||
# faster builds on docker-container setup
|
||||
sudo: false
|
||||
|
||||
# used for HHVM
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- tidy
|
||||
|
||||
# cache vendor dirs
|
||||
cache:
|
||||
directories:
|
||||
|
@ -13,29 +19,39 @@ php:
|
|||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
env:
|
||||
- DB=mysql
|
||||
- DB=pgsql
|
||||
- DB=sqlite
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
exclude:
|
||||
- php: hhvm
|
||||
env: DB=pgsql # driver for PostgreSQL currently unsupported by HHVM, requires 3rd party dependency
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
|
||||
branches:
|
||||
only:
|
||||
- v2
|
||||
|
||||
install:
|
||||
before_script:
|
||||
- composer self-update
|
||||
|
||||
# build coverage only on one build, to speed up results feedbacks
|
||||
# before_script:
|
||||
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
|
||||
# disable xdebug since we don't use code-coverage for now
|
||||
- if [[ $TRAVIS_PHP_VERSION != '5.6' && $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then phpenv config-rm xdebug.ini; fi
|
||||
# build coverage only on one build, to speed up results feedbacks
|
||||
# - if [[ "$TRAVIS_PHP_VERSION" = "5.6" ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi;
|
||||
- if [[ "$DB" = "pgsql" ]]; then psql -c 'create database wallabag;' -U postgres; fi;
|
||||
|
||||
script:
|
||||
- ant prepare
|
||||
- bin/phpunit --exclude-group command-doctrine --debug $PHPUNIT_FLAGS
|
||||
- ant prepare-$DB
|
||||
- bin/phpunit --exclude-group command-doctrine -v
|
||||
|
||||
# after_script:
|
||||
# - |
|
||||
|
|
|
@ -19,9 +19,14 @@ swiftmailer:
|
|||
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_sqlite
|
||||
path: %kernel.root_dir%/../data/db/wallabag_test.sqlite
|
||||
host: localhost
|
||||
driver: "%test_database_driver%"
|
||||
host: "%test_database_host%"
|
||||
port: "%test_database_port%"
|
||||
dbname: "%test_database_name%"
|
||||
user: "%test_database_user%"
|
||||
password: "%test_database_password%"
|
||||
charset: UTF8
|
||||
path: "%test_database_path%"
|
||||
orm:
|
||||
metadata_cache_driver:
|
||||
type: service
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is a "template" of what your parameters.yml file should look like
|
||||
parameters:
|
||||
database_driver: pdo_sqlite
|
||||
database_host: 127.0.0.1
|
||||
database_driver: pdo_sqlite
|
||||
database_host: 127.0.0.1
|
||||
database_port: ~
|
||||
database_name: symfony
|
||||
database_user: root
|
||||
|
@ -9,6 +9,14 @@ parameters:
|
|||
database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
|
||||
database_table_prefix: wallabag_
|
||||
|
||||
test_database_driver: pdo_sqlite
|
||||
test_database_host: 127.0.0.1
|
||||
test_database_port: ~
|
||||
test_database_name: ~
|
||||
test_database_user: ~
|
||||
test_database_password: ~
|
||||
test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite"
|
||||
|
||||
mailer_transport: smtp
|
||||
mailer_host: 127.0.0.1
|
||||
mailer_user: ~
|
||||
|
|
58
app/config/tests/parameters.yml.dist.mysql
Normal file
58
app/config/tests/parameters.yml.dist.mysql
Normal file
|
@ -0,0 +1,58 @@
|
|||
# This file is a "template" of what your parameters.yml file should look like
|
||||
parameters:
|
||||
database_driver: pdo_sqlite
|
||||
database_host: 127.0.0.1
|
||||
database_port: ~
|
||||
database_name: symfony
|
||||
database_user: root
|
||||
database_password: ~
|
||||
database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
|
||||
database_table_prefix: wallabag_
|
||||
|
||||
test_database_driver: pdo_mysql
|
||||
test_database_host: localhost
|
||||
test_database_port: 3306
|
||||
test_database_name: wallabag
|
||||
test_database_user: root
|
||||
test_database_password: ~
|
||||
test_database_path: ~
|
||||
|
||||
mailer_transport: smtp
|
||||
mailer_host: 127.0.0.1
|
||||
mailer_user: ~
|
||||
mailer_password: ~
|
||||
|
||||
locale: en
|
||||
|
||||
# A secret key that's used to generate certain security-related tokens
|
||||
secret: ThisTokenIsNotSoSecretChangeIt
|
||||
|
||||
# wallabag misc
|
||||
app.version: 2.0.0-alpha
|
||||
|
||||
# message to display at the bottom of the page
|
||||
warning_message: >
|
||||
You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a>
|
||||
|
||||
download_pictures: false # if true, pictures will be stored into data/assets for each article
|
||||
|
||||
# Entry view
|
||||
share_twitter: true
|
||||
share_mail: true
|
||||
share_shaarli: true
|
||||
shaarli_url: http://myshaarli.com
|
||||
share_diaspora: true
|
||||
diaspora_url: http://diasporapod.com
|
||||
flattr: true
|
||||
carrot: true
|
||||
show_printlink: true
|
||||
export_epub: true
|
||||
export_mobi: true
|
||||
export_pdf: true
|
||||
|
||||
# default user config
|
||||
items_on_page: 12
|
||||
theme: material
|
||||
language: en_US
|
||||
from_email: no-reply@wallabag.org
|
||||
rss_limit: 50
|
58
app/config/tests/parameters.yml.dist.pgsql
Normal file
58
app/config/tests/parameters.yml.dist.pgsql
Normal file
|
@ -0,0 +1,58 @@
|
|||
# This file is a "template" of what your parameters.yml file should look like
|
||||
parameters:
|
||||
database_driver: pdo_sqlite
|
||||
database_host: 127.0.0.1
|
||||
database_port: ~
|
||||
database_name: symfony
|
||||
database_user: root
|
||||
database_password: ~
|
||||
database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
|
||||
database_table_prefix: wallabag_
|
||||
|
||||
test_database_driver: pdo_pgsql
|
||||
test_database_host: localhost
|
||||
test_database_port:
|
||||
test_database_name: wallabag
|
||||
test_database_user: travis
|
||||
test_database_password: ~
|
||||
test_database_path: ~
|
||||
|
||||
mailer_transport: smtp
|
||||
mailer_host: 127.0.0.1
|
||||
mailer_user: ~
|
||||
mailer_password: ~
|
||||
|
||||
locale: en
|
||||
|
||||
# A secret key that's used to generate certain security-related tokens
|
||||
secret: ThisTokenIsNotSoSecretChangeIt
|
||||
|
||||
# wallabag misc
|
||||
app.version: 2.0.0-alpha
|
||||
|
||||
# message to display at the bottom of the page
|
||||
warning_message: >
|
||||
You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a>
|
||||
|
||||
download_pictures: false # if true, pictures will be stored into data/assets for each article
|
||||
|
||||
# Entry view
|
||||
share_twitter: true
|
||||
share_mail: true
|
||||
share_shaarli: true
|
||||
shaarli_url: http://myshaarli.com
|
||||
share_diaspora: true
|
||||
diaspora_url: http://diasporapod.com
|
||||
flattr: true
|
||||
carrot: true
|
||||
show_printlink: true
|
||||
export_epub: true
|
||||
export_mobi: true
|
||||
export_pdf: true
|
||||
|
||||
# default user config
|
||||
items_on_page: 12
|
||||
theme: material
|
||||
language: en_US
|
||||
from_email: no-reply@wallabag.org
|
||||
rss_limit: 50
|
58
app/config/tests/parameters.yml.dist.sqlite
Normal file
58
app/config/tests/parameters.yml.dist.sqlite
Normal file
|
@ -0,0 +1,58 @@
|
|||
# This file is a "template" of what your parameters.yml file should look like
|
||||
parameters:
|
||||
database_driver: pdo_sqlite
|
||||
database_host: 127.0.0.1
|
||||
database_port: ~
|
||||
database_name: symfony
|
||||
database_user: root
|
||||
database_password: ~
|
||||
database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
|
||||
database_table_prefix: wallabag_
|
||||
|
||||
test_database_driver: pdo_sqlite
|
||||
test_database_host: localhost
|
||||
test_database_port:
|
||||
test_database_name: ~
|
||||
test_database_user: ~
|
||||
test_database_password: ~
|
||||
test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite"
|
||||
|
||||
mailer_transport: smtp
|
||||
mailer_host: 127.0.0.1
|
||||
mailer_user: ~
|
||||
mailer_password: ~
|
||||
|
||||
locale: en
|
||||
|
||||
# A secret key that's used to generate certain security-related tokens
|
||||
secret: ThisTokenIsNotSoSecretChangeIt
|
||||
|
||||
# wallabag misc
|
||||
app.version: 2.0.0-alpha
|
||||
|
||||
# message to display at the bottom of the page
|
||||
warning_message: >
|
||||
You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a>
|
||||
|
||||
download_pictures: false # if true, pictures will be stored into data/assets for each article
|
||||
|
||||
# Entry view
|
||||
share_twitter: true
|
||||
share_mail: true
|
||||
share_shaarli: true
|
||||
shaarli_url: http://myshaarli.com
|
||||
share_diaspora: true
|
||||
diaspora_url: http://diasporapod.com
|
||||
flattr: true
|
||||
carrot: true
|
||||
show_printlink: true
|
||||
export_epub: true
|
||||
export_mobi: true
|
||||
export_pdf: true
|
||||
|
||||
# default user config
|
||||
items_on_page: 12
|
||||
theme: material
|
||||
language: en_US
|
||||
from_email: no-reply@wallabag.org
|
||||
rss_limit: 50
|
52
build.xml
52
build.xml
|
@ -1,17 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="wallabag" default="build">
|
||||
<target name="build" depends="prepare"/>
|
||||
<target name="build" depends="clean,composer,prepare,phpunit"/>
|
||||
<target name="prepare-mysql" depends="clean,composer,db_mysql,prepare"/>
|
||||
<target name="prepare-sqlite" depends="clean,composer,db_sqlite,prepare"/>
|
||||
<target name="prepare-pgsql" depends="clean,composer,db_pgsql,prepare"/>
|
||||
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/app/cache"/>
|
||||
</target>
|
||||
|
||||
<target name="prepare" depends="clean" description="Prepare for build">
|
||||
<target name="composer" description="Install deps using Composer">
|
||||
<exec executable="composer">
|
||||
<arg value="install"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="prepare" description="Prepare for build">
|
||||
<exec executable="php">
|
||||
<arg value="${basedir}/app/console"/>
|
||||
<arg value="doctrine:database:drop"/>
|
||||
|
@ -41,6 +47,48 @@
|
|||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="db_mysql" description="Run test for MySQL">
|
||||
<delete dir="${basedir}/app/config/parameters.yml"/>
|
||||
<exec executable="cp">
|
||||
<arg value="${basedir}/app/config/tests/parameters.yml.dist.mysql"/>
|
||||
<arg value="${basedir}/app/config/parameters.yml"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="php">
|
||||
<arg value="${basedir}/app/console"/>
|
||||
<arg value="cache:clear"/>
|
||||
<arg value="--env=test"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="db_sqlite" description="Run test for SQLite">
|
||||
<delete dir="${basedir}/app/config/parameters.yml"/>
|
||||
<exec executable="cp">
|
||||
<arg value="${basedir}/app/config/tests/parameters.yml.dist.sqlite"/>
|
||||
<arg value="${basedir}/app/config/parameters.yml"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="php">
|
||||
<arg value="${basedir}/app/console"/>
|
||||
<arg value="cache:clear"/>
|
||||
<arg value="--env=test"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="db_pgsql" description="Run test for PostgreSQL">
|
||||
<delete dir="${basedir}/app/config/parameters.yml"/>
|
||||
<exec executable="cp">
|
||||
<arg value="${basedir}/app/config/tests/parameters.yml.dist.pgsql"/>
|
||||
<arg value="${basedir}/app/config/parameters.yml"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="php">
|
||||
<arg value="${basedir}/app/console"/>
|
||||
<arg value="cache:clear"/>
|
||||
<arg value="--env=test"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpunit" description="Run unit tests with PHPUnit + HTML Coverage">
|
||||
<exec executable="phpunit" failonerror="true">
|
||||
<arg value="--coverage-html"/>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"nelmio/api-doc-bundle": "~2.7",
|
||||
"ezyang/htmlpurifier": "~4.6",
|
||||
"mgargano/simplehtmldom": "~1.5",
|
||||
"tecnick.com/tcpdf": "~6.2",
|
||||
"tecnickcom/tcpdf": "~6.2",
|
||||
"simplepie/simplepie": "~1.3.1",
|
||||
"willdurand/hateoas-bundle": "~0.5.0",
|
||||
"htmlawed/htmlawed": "~1.1.19",
|
||||
|
|
91
composer.lock
generated
91
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "d457fa385420eb29a177ac38eac977c3",
|
||||
"hash": "350d05d95be50b6d93e8a046f784e00c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -1355,16 +1355,16 @@
|
|||
},
|
||||
{
|
||||
"name": "j0k3r/php-readability",
|
||||
"version": "v1.0.7",
|
||||
"version": "v1.0.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/j0k3r/php-readability.git",
|
||||
"reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4"
|
||||
"reference": "f71c3a419623f821c245e0a003edfbf2c67f278e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/j0k3r/php-readability/zipball/1830dc45d4fccfe09d2d107ab59890f07adc35c4",
|
||||
"reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4",
|
||||
"url": "https://api.github.com/repos/j0k3r/php-readability/zipball/f71c3a419623f821c245e0a003edfbf2c67f278e",
|
||||
"reference": "f71c3a419623f821c245e0a003edfbf2c67f278e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1414,7 +1414,7 @@
|
|||
"extraction",
|
||||
"html"
|
||||
],
|
||||
"time": "2015-09-20 19:05:55"
|
||||
"time": "2015-09-23 19:09:38"
|
||||
},
|
||||
{
|
||||
"name": "jdorn/sql-formatter",
|
||||
|
@ -2970,20 +2970,20 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/symfony",
|
||||
"version": "v2.7.4",
|
||||
"version": "v2.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/symfony.git",
|
||||
"reference": "1fdf23fe28876844b887b0e1935c9adda43ee645"
|
||||
"reference": "619528a274647cffc1792063c3ea04c4fa8266a0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/symfony/zipball/1fdf23fe28876844b887b0e1935c9adda43ee645",
|
||||
"reference": "1fdf23fe28876844b887b0e1935c9adda43ee645",
|
||||
"url": "https://api.github.com/repos/symfony/symfony/zipball/619528a274647cffc1792063c3ea04c4fa8266a0",
|
||||
"reference": "619528a274647cffc1792063c3ea04c4fa8266a0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/common": "~2.3",
|
||||
"doctrine/common": "~2.4",
|
||||
"php": ">=5.3.9",
|
||||
"psr/log": "~1.0",
|
||||
"twig/twig": "~1.20|~2.0"
|
||||
|
@ -3036,9 +3036,9 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"doctrine/data-fixtures": "1.0.*",
|
||||
"doctrine/dbal": "~2.2",
|
||||
"doctrine/dbal": "~2.4",
|
||||
"doctrine/doctrine-bundle": "~1.2",
|
||||
"doctrine/orm": "~2.2,>=2.2.3",
|
||||
"doctrine/orm": "~2.4,>=2.4.5",
|
||||
"egulias/email-validator": "~1.2",
|
||||
"ircmaxell/password-compat": "~1.0",
|
||||
"monolog/monolog": "~1.11",
|
||||
|
@ -3088,70 +3088,7 @@
|
|||
"keywords": [
|
||||
"framework"
|
||||
],
|
||||
"time": "2015-09-08 14:26:39"
|
||||
},
|
||||
{
|
||||
"name": "tecnick.com/tcpdf",
|
||||
"version": "6.2.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tecnickcom/TCPDF.git",
|
||||
"reference": "354433a33946ae7497c3eab291eaaf814bccbfab"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/354433a33946ae7497c3eab291eaaf814bccbfab",
|
||||
"reference": "354433a33946ae7497c3eab291eaaf814bccbfab",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"fonts",
|
||||
"config",
|
||||
"include",
|
||||
"tcpdf.php",
|
||||
"tcpdf_parser.php",
|
||||
"tcpdf_import.php",
|
||||
"tcpdf_barcodes_1d.php",
|
||||
"tcpdf_barcodes_2d.php",
|
||||
"include/tcpdf_colors.php",
|
||||
"include/tcpdf_filters.php",
|
||||
"include/tcpdf_font_data.php",
|
||||
"include/tcpdf_fonts.php",
|
||||
"include/tcpdf_images.php",
|
||||
"include/tcpdf_static.php",
|
||||
"include/barcodes/datamatrix.php",
|
||||
"include/barcodes/pdf417.php",
|
||||
"include/barcodes/qrcode.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPLv3"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicola Asuni",
|
||||
"email": "info@tecnick.com",
|
||||
"homepage": "http://nicolaasuni.tecnick.com"
|
||||
}
|
||||
],
|
||||
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
|
||||
"homepage": "http://www.tcpdf.org/",
|
||||
"keywords": [
|
||||
"PDFD32000-2008",
|
||||
"TCPDF",
|
||||
"barcodes",
|
||||
"datamatrix",
|
||||
"pdf",
|
||||
"pdf417",
|
||||
"qrcode"
|
||||
],
|
||||
"time": "2015-08-02 12:30:27"
|
||||
"time": "2015-09-25 11:16:52"
|
||||
},
|
||||
{
|
||||
"name": "tecnickcom/tcpdf",
|
||||
|
|
|
@ -17,6 +17,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
{
|
||||
$entry1 = new Entry($this->getReference('admin-user'));
|
||||
$entry1->setUrl('http://0.0.0.0');
|
||||
$entry1->setReadingTime(11);
|
||||
$entry1->setDomainName('domain.io');
|
||||
$entry1->setTitle('test title entry1');
|
||||
$entry1->setContent('This is my content /o/');
|
||||
$entry1->setLanguage('en');
|
||||
|
@ -27,6 +29,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
|
||||
$entry2 = new Entry($this->getReference('admin-user'));
|
||||
$entry2->setUrl('http://0.0.0.0');
|
||||
$entry2->setReadingTime(1);
|
||||
$entry2->setDomainName('domain.io');
|
||||
$entry2->setTitle('test title entry2');
|
||||
$entry2->setContent('This is my content /o/');
|
||||
$entry2->setLanguage('fr');
|
||||
|
@ -37,6 +41,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
|
||||
$entry3 = new Entry($this->getReference('bob-user'));
|
||||
$entry3->setUrl('http://0.0.0.0');
|
||||
$entry3->setReadingTime(1);
|
||||
$entry3->setDomainName('domain.io');
|
||||
$entry3->setTitle('test title entry3');
|
||||
$entry3->setContent('This is my content /o/');
|
||||
$entry3->setLanguage('en');
|
||||
|
@ -55,6 +61,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
|
||||
$entry4 = new Entry($this->getReference('admin-user'));
|
||||
$entry4->setUrl('http://0.0.0.0');
|
||||
$entry4->setReadingTime(12);
|
||||
$entry4->setDomainName('domain.io');
|
||||
$entry4->setTitle('test title entry4');
|
||||
$entry4->setContent('This is my content /o/');
|
||||
$entry4->setLanguage('en');
|
||||
|
@ -73,10 +81,13 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
|
||||
$entry5 = new Entry($this->getReference('admin-user'));
|
||||
$entry5->setUrl('http://0.0.0.0');
|
||||
$entry5->setReadingTime(12);
|
||||
$entry5->setDomainName('domain.io');
|
||||
$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);
|
||||
|
||||
|
@ -84,6 +95,8 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
|
||||
$entry6 = new Entry($this->getReference('admin-user'));
|
||||
$entry6->setUrl('http://0.0.0.0');
|
||||
$entry6->setReadingTime(12);
|
||||
$entry6->setDomainName('domain.io');
|
||||
$entry6->setTitle('test title entry6');
|
||||
$entry6->setContent('This is my content /o/');
|
||||
$entry6->setArchived(true);
|
||||
|
|
|
@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Hateoas\Configuration\Annotation as Hateoas;
|
||||
use JMS\Serializer\Annotation\XmlRoot;
|
||||
use Wallabag\CoreBundle\Tools\Utils;
|
||||
|
||||
/**
|
||||
* Entry.
|
||||
|
@ -279,8 +278,6 @@ class Entry
|
|||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
$this->readingTime = Utils::getReadingTime($content);
|
||||
$this->domainName = parse_url($this->url, PHP_URL_HOST);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
|
|||
|
||||
use Graby\Graby;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Tools\Utils;
|
||||
|
||||
/**
|
||||
* This kind of proxy class take care of getting the content from an url
|
||||
|
@ -51,6 +52,8 @@ class ContentProxy
|
|||
$entry->setContent($html);
|
||||
$entry->setLanguage($content['language']);
|
||||
$entry->setMimetype($content['content_type']);
|
||||
$entry->setReadingTime(Utils::getReadingTime($html));
|
||||
$entry->setDomainName(parse_url($entry->getUrl(), PHP_URL_HOST));
|
||||
|
||||
if (isset($content['open_graph']['og_image'])) {
|
||||
$entry->setPreviewPicture($content['open_graph']['og_image']);
|
||||
|
|
|
@ -161,4 +161,22 @@ class EntryRepository extends EntityRepository
|
|||
|
||||
return $languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used only in test case to get the right entry associated to the right user
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function findOneByUsernameAndNotArchived($username)
|
||||
{
|
||||
return $this->createQueryBuilder('e')
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('u.username = :username')->setParameter('username', $username)
|
||||
->andWhere('e.isArchived = false')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getSingleResult();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ use Doctrine\ORM\AbstractQuery;
|
|||
|
||||
class EntryControllerTest extends WallabagCoreTestCase
|
||||
{
|
||||
public $url = 'http://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';
|
||||
|
||||
public function testLogin()
|
||||
{
|
||||
$client = $this->getClient();
|
||||
|
@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$form = $crawler->filter('button[type=submit]')->form();
|
||||
|
||||
$data = array(
|
||||
'entry[url]' => 'http://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[url]' => $this->url,
|
||||
);
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsArchived(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$client->request('GET', '/view/'.$content->getId());
|
||||
|
||||
|
@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsArchived(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$crawler = $client->request('GET', '/edit/'.$content->getId());
|
||||
|
||||
|
@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsArchived(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$crawler = $client->request('GET', '/edit/'.$content->getId());
|
||||
|
||||
|
@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsArchived(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$client->request('GET', '/archive/'.$content->getId());
|
||||
|
||||
|
@ -174,7 +176,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$res = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneById($content->getId());
|
||||
->find($content->getId());
|
||||
|
||||
$this->assertEquals($res->isArchived(), true);
|
||||
}
|
||||
|
@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsStarred(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$client->request('GET', '/star/'.$content->getId());
|
||||
|
||||
|
@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsStarred(false);
|
||||
->findOneByUrl($this->url);
|
||||
|
||||
$client->request('GET', '/delete/'.$content->getId());
|
||||
|
||||
|
@ -222,21 +224,15 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
public function testViewOtherUserEntry()
|
||||
{
|
||||
$this->logInAs('bob');
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->createQueryBuilder('e')
|
||||
->select('e.id')
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('u.username != :username')->setParameter('username', 'bob')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getSingleResult(AbstractQuery::HYDRATE_ARRAY);
|
||||
->findOneByUsernameAndNotArchived('bob');
|
||||
|
||||
$client->request('GET', '/view/'.$content['id']);
|
||||
$client->request('GET', '/view/'.$content->getId());
|
||||
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
@ -334,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$crawler = $client->request('GET', '/unread/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = array(
|
||||
'entry_filter[domainName]' => 'monde',
|
||||
'entry_filter[domainName]' => 'domain',
|
||||
);
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(5, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = array(
|
||||
|
@ -360,14 +356,14 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$form['entry_filter[isStarred]']->untick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$form['entry_filter[isArchived]']->untick();
|
||||
$form['entry_filter[isStarred]']->tick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
|
||||
public function testPreviewPictureFilter()
|
||||
|
@ -391,11 +387,11 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$crawler = $client->request('GET', '/unread/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = array(
|
||||
'entry_filter[language]' => 'de',
|
||||
'entry_filter[language]' => 'fr',
|
||||
);
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = array(
|
||||
|
|
|
@ -24,7 +24,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||
$entry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneBy(array());
|
||||
->findOneByUsernameAndNotArchived('admin');
|
||||
|
||||
$crawler = $client->request('GET', '/view/'.$entry->getId());
|
||||
|
||||
|
@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||
$newEntry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneById($entry->getId());
|
||||
->find($entry->getId());
|
||||
|
||||
$this->assertEquals(1, count($newEntry->getTags()));
|
||||
|
||||
|
@ -61,7 +61,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||
$newEntry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneById($entry->getId());
|
||||
->find($entry->getId());
|
||||
|
||||
$this->assertEquals(2, count($newEntry->getTags()));
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ class ContentProxyTest extends KernelTestCase
|
|||
$this->assertEmpty($entry->getPreviewPicture());
|
||||
$this->assertEmpty($entry->getMimetype());
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
$this->assertEquals(0.0, $entry->getReadingTime());
|
||||
$this->assertEquals('0.0.0.0', $entry->getDomainName());
|
||||
}
|
||||
|
||||
public function testWithEmptyContentButOG()
|
||||
|
@ -59,14 +61,16 @@ class ContentProxyTest extends KernelTestCase
|
|||
));
|
||||
|
||||
$proxy = new ContentProxy($graby);
|
||||
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
|
||||
$entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
|
||||
|
||||
$this->assertEquals('http://0.0.0.0', $entry->getUrl());
|
||||
$this->assertEquals('http://domain.io', $entry->getUrl());
|
||||
$this->assertEquals('my title', $entry->getTitle());
|
||||
$this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent());
|
||||
$this->assertEmpty($entry->getPreviewPicture());
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
$this->assertEmpty($entry->getMimetype());
|
||||
$this->assertEquals(0.0, $entry->getReadingTime());
|
||||
$this->assertEquals('domain.io', $entry->getDomainName());
|
||||
}
|
||||
|
||||
public function testWithContent()
|
||||
|
@ -79,7 +83,7 @@ class ContentProxyTest extends KernelTestCase
|
|||
$graby->expects($this->any())
|
||||
->method('fetchContent')
|
||||
->willReturn(array(
|
||||
'html' => 'this is my content',
|
||||
'html' => str_repeat('this is my content', 325),
|
||||
'title' => 'this is my title',
|
||||
'url' => 'http://1.1.1.1',
|
||||
'content_type' => 'text/html',
|
||||
|
@ -96,9 +100,11 @@ class ContentProxyTest extends KernelTestCase
|
|||
|
||||
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
|
||||
$this->assertEquals('this is my title', $entry->getTitle());
|
||||
$this->assertEquals('this is my content', $entry->getContent());
|
||||
$this->assertContains('this is my content', $entry->getContent());
|
||||
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
|
||||
$this->assertEquals('text/html', $entry->getMimetype());
|
||||
$this->assertEquals('fr', $entry->getLanguage());
|
||||
$this->assertEquals(4.0, $entry->getReadingTime());
|
||||
$this->assertEquals('1.1.1.1', $entry->getDomainName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue