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_TIMEZONE=America/Los_Angeles
|
||||||
APP_URL=http://localhost/
|
APP_URL=http://localhost/
|
||||||
|
|
||||||
TESTING_DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
TESTING_DB_DATABASE=panel_test
|
DB_DATABASE=panel_test
|
||||||
TESTING_DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
TESTING_DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
|
|
||||||
CACHE_DRIVER=array
|
CACHE_DRIVER=array
|
||||||
SESSION_DRIVER=array
|
SESSION_DRIVER=array
|
||||||
|
|
9
.github/workflows/tests.yml
vendored
9
.github/workflows/tests.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php: [ 7.4, 8.0 ]
|
php: [ 7.4, 8.0, 8.1 ]
|
||||||
database: [ 'mariadb:10.2', 'mysql:8' ]
|
database: [ 'mariadb:10.2', 'mysql:8' ]
|
||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
|
@ -50,10 +50,9 @@ jobs:
|
||||||
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
|
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
DB_CONNECTION: testing
|
DB_HOST: UNIT_NO_DB
|
||||||
TESTING_DB_HOST: UNIT_NO_DB
|
|
||||||
- name: execute integration tests
|
- name: execute integration tests
|
||||||
run: vendor/bin/phpunit tests/Integration
|
run: vendor/bin/phpunit tests/Integration
|
||||||
env:
|
env:
|
||||||
TESTING_DB_PORT: ${{ job.services.database.ports[3306] }}
|
DB_PORT: ${{ job.services.database.ports[3306] }}
|
||||||
TESTING_DB_USERNAME: root
|
DB_USERNAME: root
|
||||||
|
|
|
@ -22,9 +22,10 @@ $kernel->bootstrap();
|
||||||
|
|
||||||
$output = new ConsoleOutput();
|
$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>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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +35,10 @@ if (config('database.default') !== 'testing') {
|
||||||
*/
|
*/
|
||||||
if (!env('SKIP_MIGRATIONS')) {
|
if (!env('SKIP_MIGRATIONS')) {
|
||||||
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
|
$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);
|
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
|
||||||
$kernel->call('db:seed', ['--database' => 'testing']);
|
$kernel->call('db:seed');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
|
$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),
|
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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
backupGlobals="false"
|
bootstrap="bootstrap/tests.php"
|
||||||
backupStaticAttributes="false"
|
colors="true"
|
||||||
bootstrap="bootstrap/tests.php"
|
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
|
||||||
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"
|
|
||||||
>
|
>
|
||||||
<coverage processUncoveredFiles="true">
|
<coverage processUncoveredFiles="true">
|
||||||
<include>
|
<include>
|
||||||
|
@ -19,20 +11,18 @@
|
||||||
</include>
|
</include>
|
||||||
</coverage>
|
</coverage>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Browser">
|
|
||||||
<directory suffix="Test.php">./tests/Browser/Processes</directory>
|
|
||||||
</testsuite>
|
|
||||||
<testsuite name="Integration">
|
<testsuite name="Integration">
|
||||||
<directory suffix="Test.php">./tests/Integration</directory>
|
<directory>./tests/Integration</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="Unit">
|
<testsuite name="Unit">
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
<directory>./tests/Unit</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<php>
|
<php>
|
||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
<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="CACHE_DRIVER" value="array"/>
|
||||||
<env name="SESSION_DRIVER" value="array"/>
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
|
Loading…
Reference in a new issue