mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +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:
@@ -27,8 +27,13 @@ class ApiSerializerTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function prepDb()
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
$this->normalUser()
|
||||
@@ -42,8 +47,6 @@ class ApiSerializerTest extends TestCase
|
||||
['id' => 1, 'discussion_id' => 3, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2, 'type' => 'discussionRenamed', 'content' => '<t><p>can i haz relationz?</p></t>'],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->app();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,8 +332,6 @@ class ApiSerializerTest extends TestCase
|
||||
->hasMany('customSerializerRelation', DiscussionSerializer::class)
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
@@ -356,8 +357,6 @@ class ApiSerializerTest extends TestCase
|
||||
->hasOne('customSerializerRelation', DiscussionSerializer::class)
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
@@ -385,8 +384,6 @@ class ApiSerializerTest extends TestCase
|
||||
})
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
@@ -412,8 +409,6 @@ class ApiSerializerTest extends TestCase
|
||||
->relationship('customSerializerRelation', CustomRelationshipInvokableClass::class)
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
@@ -439,8 +434,6 @@ class ApiSerializerTest extends TestCase
|
||||
->hasMany('anotherCustomRelation', DiscussionSerializer::class)
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
@@ -472,8 +465,6 @@ class ApiSerializerTest extends TestCase
|
||||
})
|
||||
);
|
||||
|
||||
$this->prepDb();
|
||||
|
||||
$request = $this->request('GET', '/api/users/2', [
|
||||
'authenticatedAs' => 1,
|
||||
]);
|
||||
|
Reference in New Issue
Block a user