Skip to content

Commit d0b4a37

Browse files
authored
test: change base connection testcase (#399)
* test: change base connection testcase * ci * revent ci
1 parent a295c79 commit d0b4a37

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.github/workflows/database.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Database
22

3-
on:
3+
on:
44
push:
55
paths:
66
- ".github/workflows/database.yml"

src/System/Integrate/Console/MigrationCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public function databaseShow(): int
502502
}
503503

504504
foreach ($tables as $table) {
505+
$table = array_change_key_case($table);
505506
$name = $table['table_name'];
506507
$time = $table['create_time'];
507508
$size = $table['size'];

tests/Integrate/Commands/MigrationCommandsTest.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,31 @@
44

55
namespace System\Test\Integrate\Commands;
66

7+
use System\Database\MyPDO;
78
use System\Database\MySchema\Table\Create;
89
use System\Integrate\Application;
910
use System\Integrate\Console\MigrationCommand;
10-
use System\Support\Facades\PDO as FacadesPDO;
11+
use System\Support\Facades\Facade;
1112
use System\Support\Facades\Schema;
13+
use System\Test\Database\BaseConnection;
1214
use System\Text\Str;
1315

14-
final class MigrationCommandsTest extends \RealDatabaseConnectionTest
16+
final class MigrationCommandsTest extends BaseConnection
1517
{
1618
private Application $app;
1719

1820
protected function setUp(): void
1921
{
20-
parent::setUp();
22+
$this->createConnection();
23+
2124
$this->app = new Application(__DIR__);
2225
$this->app->setMigrationPath('/database/migration/');
2326
$this->app->set('environment', 'dev');
24-
new Schema($this->app);
25-
new FacadesPDO($this->app);
26-
$this->app->set(\System\Database\MyPDO::class, $this->pdo);
27-
$this->app->set('MySchema', $this->schema);
28-
$this->app->set('dsn.sql', $this->env);
27+
$this->app->set(MyPDO::class, fn () => $this->pdo);
28+
$this->app->set('MySchema', fn () => $this->schema);
29+
$this->app->set('dsn.sql', fn () => $this->env);
30+
31+
Facade::setFacadeBase($this->app);
2932
Schema::table('migration', function (Create $column) {
3033
$column('migration')->varchar(100)->notNull();
3134
$column('batch')->int(4)->notNull();
@@ -36,7 +39,7 @@ protected function setUp(): void
3639

3740
protected function tearDown(): void
3841
{
39-
parent::tearDown();
42+
$this->dropConnection();
4043
Schema::drop()->table('migartion')->ifExists()->execute();
4144
MigrationCommand::flushVendorMigrationPaths();
4245
$this->app->flush();
@@ -158,7 +161,7 @@ public function itCanRunDatabaseShow()
158161
$out = ob_get_clean();
159162

160163
$this->assertEquals(0, $exit);
161-
$this->assertTrue(Str::contains($out, 'users'));
164+
$this->assertTrue(Str::contains($out, 'migration'));
162165
}
163166

164167
/**

0 commit comments

Comments
 (0)