Skip to content

Commit

Permalink
remove testing specific db connection config #108
Browse files Browse the repository at this point in the history
  • Loading branch information
beesaferoot committed Dec 29, 2024
1 parent 4ca2a7a commit 4a56435
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
php artisan migrate:fresh --seed
working-directory: ./src/backend
env:
DB_CONNECTION: testing
DB_CONNECTION: micro_power_manager
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: testing_test_company_db
Expand All @@ -60,7 +60,7 @@ jobs:
working-directory: ./src/backend
continue-on-error: true
env:
DB_CONNECTION: testing
DB_CONNECTION: micro_power_manager
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: testing_test_company_db
Expand Down
36 changes: 0 additions & 36 deletions src/backend/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,6 @@
'strict' => false,
'engine' => null,
],

// PHPunit testing main connection
'testing' => [
// 'driver' => 'sqlite',
// 'database' => ':memory:',
// 'prefix' => '',
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'testing_test_company_db'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'wF9zLp2qRxaS2e'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],

// PHPunit testing test_db connection
'testing_test_company_db' => [
// 'driver' => 'sqlite',
// 'database' => ':memory:',
// 'prefix' => '',
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'testing_test_company_db'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'wF9zLp2qRxaS2e'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/database/factories/AgentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function definition() {
'balance' => 0,
'commission_revenue' => 0,
'due_to_energy_supplier' => 0,
'connection' => 'testing_test_company_db',
'connection' => 'shard',
];
}
}
7 changes: 3 additions & 4 deletions src/backend/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
</whitelist>
</filter>
<php>
<env name="sample" value="en"/>
<ini name="memory_limit" value="512M"/>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="testing"/>
<env name="TEST_DB_CONNECTION" value="testing_test_company_db"/>
<env name="DB_CONNECTION" value="micro_power_manager" force="true" />
<env name="DB_HOST" value="127.0.0.1"/>
<env name="DB_PORT" value="3306"/>
<env name="DB_DATABASE" value="testing_test_company_db"/>
<env name="DB_DATABASE" value="DemoCompany_1" force="true"/>
<env name="DB_USERNAME" value="root"/>
<env name="DB_PASSWORD" value="wF9zLp2qRxaS2e"/>
</php>
Expand Down
8 changes: 4 additions & 4 deletions src/backend/tests/RefreshMultipleDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ trait RefreshMultipleDatabases {
protected function refreshInMemoryDatabase() {
Artisan::call(
'migrate:fresh',
['--database' => 'micro_power_manager', '--path' => '/database/migrations/base']
['--database' => 'micro_power_manager', '--path' => '/database/migrations/']
);
Artisan::call(
'migrate:fresh',
['--database' => 'testing_test_company_db', '--path' => '/database/migrations/testing_test_company_db']
['--database' => 'DemoCompany_1', '--path' => '/database/migrations/micropowermanager']
);
app(Kernel::class)->setArtisan(null);
$this->app[Kernel::class]->setArtisan(null);
Expand All @@ -27,12 +27,12 @@ protected function refreshTestDatabase() {
if (!RefreshDatabaseState::$migrated) {
Artisan::call(
'migrate:fresh',
['--database' => 'micro_power_manager', '--path' => '/database/migrations/base']
['--database' => 'micro_power_manager', '--path' => '/database/migrations/']
);

Artisan::call(
'migrate:fresh',
['--database' => 'testing_test_company_db', '--path' => '/database/migrations/testing_test_company_db']
['--database' => 'DemoCompany_1', '--path' => '/database/migrations/micropowermanager']
);

app(Kernel::class)->setArtisan(null);
Expand Down

0 comments on commit 4a56435

Please sign in to comment.