1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 16:07:34 +02:00

Make integration tests independent

This creates a dedicated test suite for integration tests. All of them
can be run independently, and there is no order dependency - previously,
all integration tests needed the installer test to run first, and they
would fail if installation failed.

Now, the developer will have to set up a Flarum database to be used by
these tests. A setup script to make this simple will be added in the
next commit.

Small tradeoff: the installer is NOT tested in our test suite anymore,
only implicitly through the setup script. If we decide that this is a
problem, we can still set up separate, dedicated installer tests which
should probably test the web installer.
This commit is contained in:
Franz Liedke
2019-01-30 21:15:27 +01:00
parent 4d10536d35
commit cf746079ed
22 changed files with 416 additions and 419 deletions

View File

@@ -11,13 +11,38 @@
namespace Flarum\Tests\integration\api\Controller;
use Carbon\Carbon;
use Flarum\Api\Controller\ListDiscussionsController;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class ListDiscussionsControllerTest extends ApiControllerTestCase
{
protected $controller = ListDiscussionsController::class;
public function setUp()
{
parent::setUp();
$this->prepareDatabase([
'discussions' => [
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2, 'first_post_id' => 1, 'comment_count' => 1],
],
'posts' => [
['id' => 1, 'discussion_id' => 1, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>'],
],
'users' => [
$this->normalUser(),
],
'groups' => [
$this->memberGroup(),
$this->guestGroup(),
],
'group_permission' => [
['permission' => 'viewDiscussions', 'group_id' => 2],
]
]);
}
/**
* @test
*/
@@ -28,7 +53,7 @@ class ListDiscussionsControllerTest extends ApiControllerTestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(Discussion::count(), count($data['data']));
$this->assertEquals(1, count($data['data']));
}
/**
@@ -36,7 +61,7 @@ class ListDiscussionsControllerTest extends ApiControllerTestCase
*/
public function can_search_for_author()
{
$user = $this->getNormalUser();
$user = User::find(2);
$response = $this->callWith([], [
'filter' => [