Move trait to base test class

This way, its properties can be overwritten in subclasses of
`ApiControllerTestCase`. This isn't allowed when those subclasses
use the trait directly.
This commit is contained in:
Franz Liedke 2018-11-09 11:20:48 +01:00
parent f41ae92f1a
commit 99f9ec45f1
8 changed files with 3 additions and 21 deletions

View File

@ -11,6 +11,7 @@
namespace Flarum\Tests\Api\Controller; namespace Flarum\Tests\Api\Controller;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
use Flarum\Tests\Test\TestCase; use Flarum\Tests\Test\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
@ -19,6 +20,8 @@ use Psr\Http\Server\RequestHandlerInterface;
abstract class ApiControllerTestCase extends TestCase abstract class ApiControllerTestCase extends TestCase
{ {
use RetrievesAuthorizedUsers;
/** /**
* @var RequestHandlerInterface * @var RequestHandlerInterface
*/ */

View File

@ -14,13 +14,10 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\CreateDiscussionController; use Flarum\Api\Controller\CreateDiscussionController;
use Flarum\Discussion\Discussion; use Flarum\Discussion\Discussion;
use Flarum\Post\Post; use Flarum\Post\Post;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
class CreateDiscussionControllerTest extends ApiControllerTestCase class CreateDiscussionControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = CreateDiscussionController::class; protected $controller = CreateDiscussionController::class;
protected $data = [ protected $data = [

View File

@ -13,13 +13,10 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\CreateGroupController; use Flarum\Api\Controller\CreateGroupController;
use Flarum\Group\Group; use Flarum\Group\Group;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class CreateGroupControllerTest extends ApiControllerTestCase class CreateGroupControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = CreateGroupController::class; protected $controller = CreateGroupController::class;
protected $data = [ protected $data = [

View File

@ -13,13 +13,10 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\CreatePostController; use Flarum\Api\Controller\CreatePostController;
use Flarum\Discussion\Discussion; use Flarum\Discussion\Discussion;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
class CreatePostControllerTest extends ApiControllerTestCase class CreatePostControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = CreatePostController::class; protected $controller = CreatePostController::class;
protected $data = [ protected $data = [

View File

@ -13,12 +13,9 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\CreateTokenController; use Flarum\Api\Controller\CreateTokenController;
use Flarum\Http\AccessToken; use Flarum\Http\AccessToken;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
class CreateTokenControllerTest extends ApiControllerTestCase class CreateTokenControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = CreateTokenController::class; protected $controller = CreateTokenController::class;
/** /**

View File

@ -13,14 +13,11 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\CreateUserController; use Flarum\Api\Controller\CreateUserController;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
class CreateUserControllerTest extends ApiControllerTestCase class CreateUserControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = CreateUserController::class; protected $controller = CreateUserController::class;
protected $data = [ protected $data = [

View File

@ -13,12 +13,9 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\DeleteDiscussionController; use Flarum\Api\Controller\DeleteDiscussionController;
use Flarum\Discussion\Discussion; use Flarum\Discussion\Discussion;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
class DeleteDiscussionControllerTest extends ApiControllerTestCase class DeleteDiscussionControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = DeleteDiscussionController::class; protected $controller = DeleteDiscussionController::class;
protected $discussion; protected $discussion;

View File

@ -13,12 +13,9 @@ namespace Flarum\Tests\Api\Controller;
use Flarum\Api\Controller\ListDiscussionsController; use Flarum\Api\Controller\ListDiscussionsController;
use Flarum\Discussion\Discussion; use Flarum\Discussion\Discussion;
use Flarum\Tests\Test\Concerns\RetrievesAuthorizedUsers;
class ListDiscussionControllerTest extends ApiControllerTestCase class ListDiscussionControllerTest extends ApiControllerTestCase
{ {
use RetrievesAuthorizedUsers;
protected $controller = ListDiscussionsController::class; protected $controller = ListDiscussionsController::class;
/** /**