Skip to content

Commit 66da520

Browse files
committed
Simplify testing process for integration tests, don't require second connection
1 parent 8c63eeb commit 66da520

File tree

5 files changed

+22
-55
lines changed

5 files changed

+22
-55
lines changed

.env.ci

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ APP_THEME=pterodactyl
55
APP_TIMEZONE=America/Los_Angeles
66
APP_URL=http://localhost/
77

8-
TESTING_DB_HOST=127.0.0.1
9-
TESTING_DB_DATABASE=panel_test
10-
TESTING_DB_USERNAME=root
11-
TESTING_DB_PASSWORD=
8+
DB_HOST=127.0.0.1
9+
DB_DATABASE=panel_test
10+
DB_USERNAME=root
11+
DB_PASSWORD=
1212

1313
CACHE_DRIVER=array
1414
SESSION_DRIVER=array

.github/workflows/tests.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
php: [ 7.4, 8.0 ]
15+
php: [ 7.4, 8.0, 8.1 ]
1616
database: [ 'mariadb:10.2', 'mysql:8' ]
1717
services:
1818
database:
@@ -50,10 +50,9 @@ jobs:
5050
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
5151
if: ${{ always() }}
5252
env:
53-
DB_CONNECTION: testing
54-
TESTING_DB_HOST: UNIT_NO_DB
53+
DB_HOST: UNIT_NO_DB
5554
- name: execute integration tests
5655
run: vendor/bin/phpunit tests/Integration
5756
env:
58-
TESTING_DB_PORT: ${{ job.services.database.ports[3306] }}
59-
TESTING_DB_USERNAME: root
57+
DB_PORT: ${{ job.services.database.ports[3306] }}
58+
DB_USERNAME: root

bootstrap/tests.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
$output = new ConsoleOutput();
2424

25-
if (config('database.default') !== 'testing') {
25+
$prefix = 'database.connections.' . config('database.default');
26+
if (config("$prefix.database") !== 'panel_test') {
2627
$output->writeln(PHP_EOL . '<error>Cannot run test process against non-testing database.</error>');
27-
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config('database.default') . '".</error>');
28+
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config("$prefix.database") . '".</error>');
2829
exit(1);
2930
}
3031

@@ -34,10 +35,10 @@
3435
*/
3536
if (!env('SKIP_MIGRATIONS')) {
3637
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
37-
$kernel->call('migrate:fresh', ['--database' => 'testing']);
38+
$kernel->call('migrate:fresh');
3839

3940
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
40-
$kernel->call('db:seed', ['--database' => 'testing']);
41+
$kernel->call('db:seed');
4142
} else {
4243
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
4344
}

config/database.php

-23
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,6 @@
5757
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => env('MYSQL_ATTR_SSL_VERIFY_SERVER_CERT', true),
5858
]) : [],
5959
],
60-
61-
/*
62-
| -------------------------------------------------------------------------
63-
| Test Database Connection
64-
| -------------------------------------------------------------------------
65-
|
66-
| This connection is used by the integration and HTTP tests for Pterodactyl
67-
| development. Normal users of the Panel do not need to adjust any settings
68-
| in here.
69-
*/
70-
'testing' => [
71-
'driver' => 'mysql',
72-
'host' => env('TESTING_DB_HOST', '127.0.0.1'),
73-
'port' => env('TESTING_DB_PORT', '3306'),
74-
'database' => env('TESTING_DB_DATABASE', 'panel_test'),
75-
'username' => env('TESTING_DB_USERNAME', 'pterodactyl_test'),
76-
'password' => env('TESTING_DB_PASSWORD', ''),
77-
'charset' => 'utf8mb4',
78-
'collation' => 'utf8mb4_unicode_ci',
79-
'prefix' => '',
80-
'strict' => false,
81-
'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))),
82-
],
8360
],
8461

8562
/*

phpunit.xml

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
bootstrap="bootstrap/tests.php"
7-
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="bootstrap/tests.php"
5+
colors="true"
6+
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
157
>
168
<coverage processUncoveredFiles="true">
179
<include>
1810
<directory suffix=".php">./app</directory>
1911
</include>
2012
</coverage>
2113
<testsuites>
22-
<testsuite name="Browser">
23-
<directory suffix="Test.php">./tests/Browser/Processes</directory>
24-
</testsuite>
2514
<testsuite name="Integration">
26-
<directory suffix="Test.php">./tests/Integration</directory>
15+
<directory>./tests/Integration</directory>
2716
</testsuite>
2817
<testsuite name="Unit">
29-
<directory suffix="Test.php">./tests/Unit</directory>
18+
<directory>./tests/Unit</directory>
3019
</testsuite>
3120
</testsuites>
3221
<php>
3322
<env name="APP_ENV" value="testing"/>
3423
<env name="BCRYPT_ROUNDS" value="4"/>
35-
<env name="DB_CONNECTION" value="testing"/>
24+
<env name="DB_CONNECTION" value="mysql"/>
25+
<env name="DB_DATABASE" value="panel_test"/>
3626
<env name="CACHE_DRIVER" value="array"/>
3727
<env name="SESSION_DRIVER" value="array"/>
3828
<env name="QUEUE_CONNECTION" value="sync"/>

0 commit comments

Comments
 (0)