docs and tests configuration for mysql support

This commit is contained in:
Mitchell Hewes 2017-01-11 11:41:54 +11:00
parent 0a3292ae58
commit 8cd29d3600
8 changed files with 58 additions and 5 deletions

View File

@ -26,10 +26,14 @@ script:
- ./node_modules/.bin/jshint assets/js/src/*.js
- ./vendor/bin/phpunit -c tests/phpunit.unit.sqlite.xml
- ./vendor/bin/phpunit -c tests/phpunit.unit.postgres.xml
- ./vendor/bin/phpunit -c tests/phpunit.unit.mysql.xml
- ./vendor/bin/phpunit -c tests/phpunit.functional.sqlite.xml
- cp ./tests/ci/config.postgres.php $TRAVIS_BUILD_DIR/config.php
- ./vendor/bin/phpunit -c tests/phpunit.functional.postgres.xml tests/functional/ApiTest.php
- ./vendor/bin/phpunit -c tests/phpunit.functional.postgres.xml tests/functional/FeverApiTest.php
- cp ./tests/ci/config.mysql.php $TRAVIS_BUILD_DIR/config.php
- ./vendor/bin/phpunit -c tests/phpunit.functional.mysql.xml tests/functional/ApiTest.php
- ./vendor/bin/phpunit -c tests/phpunit.functional.mysql.xml tests/functional/FeverApiTest.php
after_failure:
- cat apache_error.log

View File

@ -12,7 +12,7 @@ To override them, rename the file `config.default.php` to `config.php`.
Database configuration
----------------------
By default, Miniflux uses Sqlite but Postgres and mysql are also supported.
By default, Miniflux uses Sqlite but Postgres and MySQL are also supported.
### Sqlite configuration
@ -87,11 +87,11 @@ define('FAVICON_URL_PATH', 'data/favicons');
// Database driver: "sqlite", "postgres", or "mysql" default is sqlite
define('DB_DRIVER', 'sqlite');
// Database connection parameters when Postgres or Mysql are used
// Database connection parameters when Postgres or MySQL are used
define('DB_HOSTNAME', 'localhost');
define('DB_NAME', 'miniflux');
define('DB_USERNAME', 'postgres');
define('DB_PASSWORD', '');
define('DB_USERNAME', 'my db user');
define('DB_PASSWORD', 'my secret password');
// DB_FILENAME => database file when Sqlite is used
define('DB_FILENAME', DATA_DIRECTORY.'/db.sqlite');

View File

@ -27,7 +27,7 @@ Installation
1. `git clone https://github.com/miniflux/miniflux.git`
2. Go to the third step just above
By default, Miniflux uses Sqlite, if you would like to use Postgres instead you will have to modify your `config.php` file.
By default, Miniflux uses Sqlite, if you would like to use Postgres or MySQL instead you will have to modify your `config.php` file.
Security
--------

View File

@ -0,0 +1,7 @@
<?php
defined('DB_DRIVER') or define('DB_DRIVER', 'mysql');
defined('DB_HOSTNAME') or define('DB_HOSTNAME', 'localhost');
defined('DB_NAME') or define('DB_NAME', 'miniflux_functional_test');
defined('DB_USERNAME') or define('DB_USERNAME', 'root');
defined('DB_PASSWORD') or define('DB_PASSWORD', '');

View File

@ -16,6 +16,15 @@ abstract class BaseApiTest extends PHPUnit_Framework_TestCase
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
} else if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$stmt = $pdo->query("SELECT information_schema.processlist.id FROM information_schema.processlist WHERE information_schema.processlist.DB = '".DB_NAME."' AND id <> connection_id()");
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$pdo->exec('KILL '.$row['id']);
}
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
} else if (file_exists(DB_FILENAME)) {
unlink(DB_FILENAME);
}

View File

@ -0,0 +1,15 @@
<phpunit stopOnError="true" stopOnFailure="true" colors="true">
<testsuites>
<testsuite name="Miniflux MySQL Functional Tests">
<directory>functional</directory>
</testsuite>
</testsuites>
<php>
<const name="API_URL" value="http://127.0.0.1/jsonrpc.php" />
<const name="FEVER_API_URL" value="http://127.0.0.1/fever/" />
<const name="DB_DRIVER" value="mysql" />
<const name="DB_USERNAME" value="root" />
<const name="DB_PASSWORD" value="" />
<const name="DB_NAME" value="miniflux_functional_test" />
</php>
</phpunit>

View File

@ -0,0 +1,13 @@
<phpunit stopOnError="true" stopOnFailure="true" colors="true">
<testsuites>
<testsuite name="Miniflux MySQL Unit Tests">
<directory>unit</directory>
</testsuite>
</testsuites>
<php>
<const name="DB_DRIVER" value="mysql" />
<const name="DB_USERNAME" value="root" />
<const name="DB_PASSWORD" value="" />
<const name="DB_NAME" value="miniflux_unit_test" />
</php>
</phpunit>

View File

@ -17,6 +17,11 @@ abstract class BaseTest extends PHPUnit_Framework_TestCase
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
} else if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
}
PicoDb\Database::setInstance('db', function () {