Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanhooft committed Jan 6, 2025
1 parent 0e9384b commit 9f69805
Showing 1 changed file with 18 additions and 33 deletions.
51 changes: 18 additions & 33 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class BaseTestCase extends TestCase
{
use InteractsWithMocks;

private const MIGRATIONS_PATH = __DIR__.'/../database/migrations';

protected $interactWithMollieAPI = false;

/**
Expand Down Expand Up @@ -49,40 +51,23 @@ protected function getPackageProviders($app)

protected function setupDatabase(): void
{
$migrations_dir = __DIR__ . '/../database/migrations';

$this->runMigrations(
collect([
__DIR__ . '/Database/Migrations/create_users_table.php',
$migrations_dir . '/create_subscriptions_table.php.stub',
$migrations_dir . '/create_order_items_table.php.stub',
$migrations_dir . '/create_orders_table.php.stub',
$migrations_dir . '/create_credits_table.php.stub',
$migrations_dir . '/create_redeemed_coupons_table.php.stub',
$migrations_dir . '/create_applied_coupons_table.php.stub',
$migrations_dir . '/create_payments_table.php.stub',
$migrations_dir . '/create_refund_items_table.php.stub',
$migrations_dir . '/create_refunds_table.php.stub',
])
);
}
/**
* Runs a collection of migrations.
*
* @param Collection $migrations
*/
protected function runMigrations(Collection $migrations)
{
$migrations->each(fn ($file_path) => $this->runMigration($file_path));
}
$migrations = collect([
__DIR__ . '/Database/Migrations/create_users_table.php',
self::MIGRATIONS_PATH. '/create_subscriptions_table.php.stub',
self::MIGRATIONS_PATH. '/create_order_items_table.php.stub',
self::MIGRATIONS_PATH. '/create_orders_table.php.stub',
self::MIGRATIONS_PATH. '/create_credits_table.php.stub',
self::MIGRATIONS_PATH. '/create_redeemed_coupons_table.php.stub',
self::MIGRATIONS_PATH. '/create_applied_coupons_table.php.stub',
self::MIGRATIONS_PATH. '/create_payments_table.php.stub',
self::MIGRATIONS_PATH. '/create_refund_items_table.php.stub',
self::MIGRATIONS_PATH. '/create_refunds_table.php.stub',
]);

/**
* @param string $file_path
*/
protected function runMigration(string $file_path)
{
$migration = include $file_path;
$migration->up();
$migrations->each(function ($file_path) {
$migration = include $file_path;
$migration->up();
});
}

/**
Expand Down

0 comments on commit 9f69805

Please sign in to comment.