Skip to content

Commit

Permalink
test: change base connection testcase (#399)
Browse files Browse the repository at this point in the history
* test: change base connection testcase

* ci

* revent ci
  • Loading branch information
SonyPradana authored Oct 25, 2024
1 parent a295c79 commit d0b4a37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Database

on:
on:
push:
paths:
- ".github/workflows/database.yml"
Expand Down
1 change: 1 addition & 0 deletions src/System/Integrate/Console/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public function databaseShow(): int
}

foreach ($tables as $table) {
$table = array_change_key_case($table);
$name = $table['table_name'];
$time = $table['create_time'];
$size = $table['size'];
Expand Down
23 changes: 13 additions & 10 deletions tests/Integrate/Commands/MigrationCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@

namespace System\Test\Integrate\Commands;

use System\Database\MyPDO;
use System\Database\MySchema\Table\Create;
use System\Integrate\Application;
use System\Integrate\Console\MigrationCommand;
use System\Support\Facades\PDO as FacadesPDO;
use System\Support\Facades\Facade;
use System\Support\Facades\Schema;
use System\Test\Database\BaseConnection;
use System\Text\Str;

final class MigrationCommandsTest extends \RealDatabaseConnectionTest
final class MigrationCommandsTest extends BaseConnection
{
private Application $app;

protected function setUp(): void
{
parent::setUp();
$this->createConnection();

$this->app = new Application(__DIR__);
$this->app->setMigrationPath('/database/migration/');
$this->app->set('environment', 'dev');
new Schema($this->app);
new FacadesPDO($this->app);
$this->app->set(\System\Database\MyPDO::class, $this->pdo);
$this->app->set('MySchema', $this->schema);
$this->app->set('dsn.sql', $this->env);
$this->app->set(MyPDO::class, fn () => $this->pdo);
$this->app->set('MySchema', fn () => $this->schema);
$this->app->set('dsn.sql', fn () => $this->env);

Facade::setFacadeBase($this->app);
Schema::table('migration', function (Create $column) {
$column('migration')->varchar(100)->notNull();
$column('batch')->int(4)->notNull();
Expand All @@ -36,7 +39,7 @@ protected function setUp(): void

protected function tearDown(): void
{
parent::tearDown();
$this->dropConnection();
Schema::drop()->table('migartion')->ifExists()->execute();
MigrationCommand::flushVendorMigrationPaths();
$this->app->flush();
Expand Down Expand Up @@ -158,7 +161,7 @@ public function itCanRunDatabaseShow()
$out = ob_get_clean();

$this->assertEquals(0, $exit);
$this->assertTrue(Str::contains($out, 'users'));
$this->assertTrue(Str::contains($out, 'migration'));
}

/**
Expand Down

0 comments on commit d0b4a37

Please sign in to comment.