-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88a8e97
commit ecc77ed
Showing
21 changed files
with
455 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Database; | ||
|
||
use Illuminate\Database\Migrations\Migration as BaseMigration; | ||
use Illuminate\Database\Query\Builder; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
abstract class Migration extends BaseMigration | ||
{ | ||
protected string $tableName; | ||
|
||
public function up(): void | ||
{ | ||
$this->createTable(); | ||
$this->fillTable(); | ||
} | ||
|
||
protected function createTable(): void | ||
{ | ||
Schema::create($this->tableName(), function (Blueprint $table) { | ||
$table->id(); | ||
|
||
$table->string($this->column()); | ||
|
||
$table->timestamp('created_at')->useCurrent(); | ||
$table->timestamp('updated_at')->useCurrent(); | ||
}); | ||
} | ||
|
||
protected function fillTable(): void | ||
{ | ||
circleProcess(fn (int $i) => $this->table()->insert([ | ||
$this->column() => $this->value($i), | ||
])); | ||
} | ||
|
||
protected function column(): string | ||
{ | ||
return columnName($this->tableName); | ||
} | ||
|
||
protected function value(int $index): string | ||
{ | ||
return valueName($this->tableName, $index); | ||
} | ||
|
||
protected function tableName(): string | ||
{ | ||
return tableName($this->tableName); | ||
} | ||
|
||
protected function table(): Builder | ||
{ | ||
return DB::table($this->tableName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class TestServiceProvider extends ServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
$this->bootMigrations(); | ||
} | ||
|
||
protected function bootMigrations(): void | ||
{ | ||
$this->loadMigrationsFrom(__DIR__ . '/../migrations'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Tests\Fixtures\Database\Migration; | ||
|
||
return new class extends Migration { | ||
protected string $tableName = 'foo'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Tests\Fixtures\Database\Migration; | ||
|
||
return new class extends Migration { | ||
protected string $tableName = 'bar'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Tests\Fixtures\Database\Migration; | ||
|
||
return new class extends Migration { | ||
protected string $tableName = 'baz'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
function circleProcess(Closure $callback): void | ||
{ | ||
for ($i = 0; $i < 10; $i++) { | ||
$callback($i); | ||
} | ||
} |
Oops, something went wrong.