1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 23:47:32 +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,8 +11,9 @@
namespace Flarum\Tests\integration\api\Controller;
use Carbon\Carbon;
use Flarum\Api\Controller\CreatePostController;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
use Illuminate\Support\Arr;
class CreatePostControllerTest extends ApiControllerTestCase
@@ -23,17 +24,28 @@ class CreatePostControllerTest extends ApiControllerTestCase
'content' => 'reply with predetermined content for automated testing - too-obscure'
];
/**
* @var Discussion
*/
protected $discussion;
protected function init()
public function setUp()
{
$this->actor = $this->getNormalUser();
$this->discussion = Discussion::start(__CLASS__, $this->actor);
parent::setUp();
$this->discussion->save();
$this->prepareDatabase([
'discussions' => [
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2],
],
'posts' => [],
'users' => [
$this->normalUser(),
],
'groups' => [
$this->memberGroup(),
],
'group_user' => [
['user_id' => 2, 'group_id' => 3],
],
'group_permission' => [
['permission' => 'viewDiscussions', 'group_id' => 3],
]
]);
}
/**
@@ -41,9 +53,11 @@ class CreatePostControllerTest extends ApiControllerTestCase
*/
public function can_create_reply()
{
$this->actor = User::find(2);
$body = [];
Arr::set($body, 'data.attributes', $this->data);
Arr::set($body, 'data.relationships.discussion.data.id', $this->discussion->id);
Arr::set($body, 'data.relationships.discussion.data.id', 1);
$response = $this->callWith($body);