1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 23:47:32 +02:00

Tests: remove prepDb workaround

Previously, the `prepareDatabase` method would directly modify the database, booting the app in the process. This would prevent any extenders from being applied, since `->extend()` has no effect once the app is booted.

Since the new implementation of `prepareDatabase` simply registers seed data to be applied during app boot, the workaround of sticking this seed data into `prepDb` is no longer necessary, and seed data common to all test cases in a class can be provided in `setUp`.

When needed, app boot is explicitly triggered in individual test cases by calling `$this->app()`.
This commit is contained in:
Alexander Skvortsov
2021-01-06 22:34:32 -05:00
parent 0a8816938a
commit ae280016e7
10 changed files with 96 additions and 158 deletions

View File

@@ -21,8 +21,13 @@ class ModelUrlTest extends TestCase
{
use RetrievesAuthorizedUsers;
protected function prepDb()
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();
$userClass = User::class;
$this->prepareDatabase([
'users' => [
@@ -39,8 +44,6 @@ class ModelUrlTest extends TestCase
*/
public function uses_default_driver_by_default()
{
$this->prepDb();
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
$testUser = User::find(1);
@@ -56,8 +59,6 @@ class ModelUrlTest extends TestCase
{
$this->extend((new Extend\ModelUrl(User::class))->addSlugDriver('testDriver', TestSlugDriver::class));
$this->prepDb();
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
$testUser = User::find(1);