From 5556df54f938ac4c7a9ae6311dca904cab590feb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 30 Jan 2019 21:16:25 +0100 Subject: [PATCH] Setup Composer commands for testing and setup --- composer.json | 9 +++++++ tests/integration/setup.php | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/integration/setup.php diff --git a/composer.json b/composer.json index a7ddf99df..15b2d449a 100644 --- a/composer.json +++ b/composer.json @@ -86,5 +86,14 @@ "branch-alias": { "dev-master": "0.1.x-dev" } + }, + "scripts": { + "test": [ + "@test:unit", + "@test:integration" + ], + "test:unit": "phpunit -c tests/phpunit.unit.xml", + "test:integration": "phpunit -c tests/phpunit.integration.xml", + "test:setup": "@php tests/integration/setup.php" } } diff --git a/tests/integration/setup.php b/tests/integration/setup.php new file mode 100644 index 000000000..e207e29d0 --- /dev/null +++ b/tests/integration/setup.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Install\AdminUser; +use Flarum\Install\DatabaseConfig; +use Flarum\Install\Installation; + +require __DIR__.'/../../vendor/autoload.php'; + +/* + * Setup installation configuration + */ + +$installation = new Installation( + __DIR__.'/tmp', + __DIR__.'/tmp/public', + __DIR__.'/tmp/storage' +); + +$pipeline = $installation + ->configPath('config.php') + ->debugMode(true) + ->baseUrl('http://localhost') + ->databaseConfig(new DatabaseConfig( + 'mysql', + env('DB_HOST', 'localhost'), + intval(env('DB_PORT', 3306)), + env('DB_DATABASE', 'flarum_test'), + env('DB_USERNAME', 'root'), + env('DB_PASSWORD', ''), + env('DB_PREFIX', '') + )) + ->adminUser(new AdminUser( + 'admin', + 'secret', + 'admin@flarum.email' + )) + ->settings(['mail_driver' => 'log']) + ->build(); + +/* + * Run the actual configuration + */ + +$pipeline->run();