Skip to content

Commit

Permalink
fix(BC): revert breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Jun 8, 2024
1 parent 04fcdb1 commit 2491bcf
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/Abstracts/Tests/PhpUnit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,62 @@
namespace Apiato\Core\Abstracts\Tests\PhpUnit;

use Apiato\Core\Traits\HashIdTrait;
use Apiato\Core\Traits\TestCaseTrait;
use Apiato\Core\Traits\TestTraits\PhpUnit\TestAssertionHelperTrait;
use Apiato\Core\Traits\TestTraits\PhpUnit\TestAuthHelperTrait;
use Apiato\Core\Traits\TestTraits\PhpUnit\TestRequestHelperTrait;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\RefreshDatabaseState;
use Illuminate\Foundation\Testing\TestCase as LaravelTestCase;
use Illuminate\Support\Facades\Artisan;

abstract class TestCase extends LaravelTestCase
{
use TestCaseTrait;
use TestAuthHelperTrait;
use TestRequestHelperTrait;
use TestAssertionHelperTrait;
use HashIdTrait;
use LazilyRefreshDatabase;

/**
* The base URL to use while testing the application.
*/
protected string $baseUrl;

/**
* Seed the DB on migrations.
*/
protected bool $seed = true;

protected function afterRefreshingDatabase(): void
/**
* Refresh the in-memory database.
*/
protected function refreshInMemoryDatabase(): void
{
$this->artisan('migrate', $this->migrateUsing());

// Install Passport Client for Testing
$this->setupPassportOAuth2();

$this->app[Kernel::class]->setArtisan(null);
}

/**
* Refresh a conventional test database.
*/
protected function refreshTestDatabase(): void
{
Artisan::call('passport:install');
if (!RefreshDatabaseState::$migrated) {
$this->artisan('migrate:fresh', $this->migrateFreshUsing());
$this->setupPassportOAuth2();

$this->app[Kernel::class]->setArtisan(null);

RefreshDatabaseState::$migrated = true;
}

$this->beginDatabaseTransaction();
}
}

0 comments on commit 2491bcf

Please sign in to comment.