1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 18:35:56 +02:00

adds a few additional api controller tests (#1429)

* added CreatePostControllerTest

* added DeleteDiscussionControllerTest

* added ListDiscussionControllerTest

* Apply fixes from StyleCI

[ci skip] [skip ci]
This commit is contained in:
Daniël Klabbers
2018-05-14 13:32:19 +02:00
committed by GitHub
parent 0058067b1b
commit 2a721926d3
5 changed files with 140 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Tests\Test\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;
use Psr\Http\Message\ResponseInterface;
abstract class ApiControllerTestCase extends TestCase
@@ -28,13 +29,17 @@ abstract class ApiControllerTestCase extends TestCase
*/
protected $actor = null;
protected function callWith(array $body = []): ResponseInterface
protected function callWith(array $body = [], array $queryParams = []): ResponseInterface
{
if (! Arr::get($body, 'data') && Arr::isAssoc($body)) {
$body = ['data' => ['attributes' => $body]];
}
return $this->call(
$this->controller,
$this->actor,
[],
$body ? ['data' => ['attributes' => $body]] : []
$queryParams,
$body
);
}