Skip to content

Commit

Permalink
Fixed deprecated methods in the Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Mar 14, 2024
1 parent f48a957 commit f984511
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/Database/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function schema(): SchemaBuilder

public function getAllTables(): array
{
$tables = $this->schema()->getAllTables();
$tables = method_exists($this->schema(), 'getAllTables')
? $this->schema()->getAllTables()
: $this->schema()->getTables();

$key = $this->tableNameColumn();

Expand Down
26 changes: 17 additions & 9 deletions tests/Concerns/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Concerns;

use DragonCode\MigrateDB\Constants\Drivers;
use Illuminate\Database\Schema\Builder as SchemaBuilder;
use Illuminate\Support\Facades\Config;
use Tests\Configurations\BaseConfiguration;
use Tests\Configurations\Manager;
Expand All @@ -16,27 +17,27 @@ trait Database
use HasUuidAndUlid;
use Seeders;

protected $connectors = [
protected array $connectors = [
Drivers::MYSQL => MySqlConnection::class,
Drivers::POSTGRES => PostgresConnection::class,
Drivers::SQL_SERVER => SqlServerConnection::class,
];

protected $table_foo = 'foo';
protected string $table_foo = 'foo';

protected $table_bar = 'bar';
protected string $table_bar = 'bar';

protected $table_baz = 'baz';
protected string $table_baz = 'baz';

protected $table_ulid = 'ulid_table';
protected string $table_ulid = 'ulid_table';

protected $table_uuid = 'uuid_table';
protected string $table_uuid = 'uuid_table';

protected $choice_target = 'target';
protected string $choice_target = 'target';

protected $choice_source = 'source';
protected string $choice_source = 'source';

protected $choices = [
protected array $choices = [
'target',
'source',
'none',
Expand Down Expand Up @@ -97,4 +98,11 @@ protected function runMigrations(): void
{
$this->artisan('migrate', ['--database' => $this->source_connection])->run();
}

protected function getTables(SchemaBuilder $builder): array
{
return method_exists($builder, 'getAllTables')
? $builder->getAllTables()
: $builder->getTables();
}
}
8 changes: 4 additions & 4 deletions tests/Unit/MysqlToMysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class MysqlToMysqlTest extends TestCase
{
public function testFillable()
{
$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertEmpty($this->getTables($this->targetConnection()));

$this->artisan('db:migrate', [
'--schema-from' => $this->source_connection,
Expand All @@ -26,8 +26,8 @@ public function testFillable()
->assertExitCode(0)
->run();

$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertNotEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertNotEmpty($this->getTables($this->targetConnection()));
}

public function testCount()
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/MysqlToPostgresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class MysqlToPostgresTest extends TestCase
{
public function testFillable()
{
$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertEmpty($this->getTables($this->targetConnection()));

$this->artisan('db:migrate', [
'--schema-from' => $this->source_connection,
Expand All @@ -26,8 +26,8 @@ public function testFillable()
->assertExitCode(0)
->run();

$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertNotEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertNotEmpty($this->getTables($this->targetConnection()));
}

public function testCount()
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/PostgresToMysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class PostgresToMysqlTest extends TestCase
{
public function testFillable()
{
$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertEmpty($this->getTables($this->targetConnection()));

$this->artisan('db:migrate', [
'--schema-from' => $this->source_connection,
Expand All @@ -26,8 +26,8 @@ public function testFillable()
->assertExitCode(0)
->run();

$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertNotEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertNotEmpty($this->getTables($this->targetConnection()));
}

public function testCount()
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/PostgresToPostgresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class PostgresToPostgresTest extends TestCase
{
public function testFillable()
{
$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertEmpty($this->getTables($this->targetConnection()));

$this->artisan('db:migrate', [
'--schema-from' => $this->source_connection,
Expand All @@ -26,8 +26,8 @@ public function testFillable()
->assertExitCode(0)
->run();

$this->assertNotEmpty($this->sourceConnection()->getAllTables());
$this->assertNotEmpty($this->targetConnection()->getAllTables());
$this->assertNotEmpty($this->getTables($this->sourceConnection()));
$this->assertNotEmpty($this->getTables($this->targetConnection()));
}

public function testCount()
Expand Down

0 comments on commit f984511

Please sign in to comment.