Simplify testing process for integration tests, don't require second connection
This commit is contained in:
parent
8c63eebf13
commit
66da520e11
5 changed files with 22 additions and 55 deletions
8
.env.ci
8
.env.ci
|
@ -5,10 +5,10 @@ APP_THEME=pterodactyl
|
|||
APP_TIMEZONE=America/Los_Angeles
|
||||
APP_URL=http://localhost/
|
||||
|
||||
TESTING_DB_HOST=127.0.0.1
|
||||
TESTING_DB_DATABASE=panel_test
|
||||
TESTING_DB_USERNAME=root
|
||||
TESTING_DB_PASSWORD=
|
||||
DB_HOST=127.0.0.1
|
||||
DB_DATABASE=panel_test
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
CACHE_DRIVER=array
|
||||
SESSION_DRIVER=array
|
||||
|
|
9
.github/workflows/tests.yml
vendored
9
.github/workflows/tests.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: [ 7.4, 8.0 ]
|
||||
php: [ 7.4, 8.0, 8.1 ]
|
||||
database: [ 'mariadb:10.2', 'mysql:8' ]
|
||||
services:
|
||||
database:
|
||||
|
@ -50,10 +50,9 @@ jobs:
|
|||
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
DB_CONNECTION: testing
|
||||
TESTING_DB_HOST: UNIT_NO_DB
|
||||
DB_HOST: UNIT_NO_DB
|
||||
- name: execute integration tests
|
||||
run: vendor/bin/phpunit tests/Integration
|
||||
env:
|
||||
TESTING_DB_PORT: ${{ job.services.database.ports[3306] }}
|
||||
TESTING_DB_USERNAME: root
|
||||
DB_PORT: ${{ job.services.database.ports[3306] }}
|
||||
DB_USERNAME: root
|
||||
|
|
|
@ -22,9 +22,10 @@ $kernel->bootstrap();
|
|||
|
||||
$output = new ConsoleOutput();
|
||||
|
||||
if (config('database.default') !== 'testing') {
|
||||
$prefix = 'database.connections.' . config('database.default');
|
||||
if (config("$prefix.database") !== 'panel_test') {
|
||||
$output->writeln(PHP_EOL . '<error>Cannot run test process against non-testing database.</error>');
|
||||
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config('database.default') . '".</error>');
|
||||
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config("$prefix.database") . '".</error>');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -34,10 +35,10 @@ if (config('database.default') !== 'testing') {
|
|||
*/
|
||||
if (!env('SKIP_MIGRATIONS')) {
|
||||
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
|
||||
$kernel->call('migrate:fresh', ['--database' => 'testing']);
|
||||
$kernel->call('migrate:fresh');
|
||||
|
||||
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
|
||||
$kernel->call('db:seed', ['--database' => 'testing']);
|
||||
$kernel->call('db:seed');
|
||||
} else {
|
||||
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
|
||||
}
|
||||
|
|
|
@ -57,29 +57,6 @@ return [
|
|||
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => env('MYSQL_ATTR_SSL_VERIFY_SERVER_CERT', true),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| Test Database Connection
|
||||
| -------------------------------------------------------------------------
|
||||
|
|
||||
| This connection is used by the integration and HTTP tests for Pterodactyl
|
||||
| development. Normal users of the Panel do not need to adjust any settings
|
||||
| in here.
|
||||
*/
|
||||
'testing' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('TESTING_DB_HOST', '127.0.0.1'),
|
||||
'port' => env('TESTING_DB_PORT', '3306'),
|
||||
'database' => env('TESTING_DB_DATABASE', 'panel_test'),
|
||||
'username' => env('TESTING_DB_USERNAME', 'pterodactyl_test'),
|
||||
'password' => env('TESTING_DB_PASSWORD', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => false,
|
||||
'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))),
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
28
phpunit.xml
28
phpunit.xml
|
@ -1,17 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap/tests.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="bootstrap/tests.php"
|
||||
colors="true"
|
||||
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
@ -19,20 +11,18 @@
|
|||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Browser">
|
||||
<directory suffix="Test.php">./tests/Browser/Processes</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Integration">
|
||||
<directory suffix="Test.php">./tests/Integration</directory>
|
||||
<directory>./tests/Integration</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
<directory>./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="DB_CONNECTION" value="testing"/>
|
||||
<env name="DB_CONNECTION" value="mysql"/>
|
||||
<env name="DB_DATABASE" value="panel_test"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
|
|
Loading…
Reference in a new issue