Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: change base connection testcase #399

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading