Inline test class

Refs #1977.
This commit is contained in:
Franz Liedke 2020-04-19 15:55:10 +02:00
parent 7143e13073
commit 8b808bfc85
2 changed files with 17 additions and 29 deletions

View File

@ -11,6 +11,7 @@ namespace Flarum\Tests\unit\User;
use Flarum\Event\GetPermission;
use Flarum\Tests\unit\TestCase;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
use Illuminate\Events\Dispatcher;
use Mockery as m;
@ -22,7 +23,7 @@ class AbstractPolicyTest extends TestCase
public function setUp()
{
$this->policy = m::mock(UserPolicy::class)->makePartial();
$this->policy = m::mock(CustomUserPolicy::class)->makePartial();
$this->dispatcher = new Dispatcher();
$this->dispatcher->subscribe($this->policy);
User::setEventDispatcher($this->dispatcher);
@ -46,3 +47,18 @@ class AbstractPolicyTest extends TestCase
$this->assertTrue($allowed);
}
}
class CustomUserPolicy extends AbstractPolicy
{
protected $model = User::class;
public function create(User $actor)
{
return true;
}
public function edit(User $actor, User $user)
{
return true;
}
}

View File

@ -1,28 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Tests\unit\User;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
class UserPolicy extends AbstractPolicy
{
protected $model = User::class;
public function create(User $actor)
{
return true;
}
public function edit(User $actor, User $user)
{
return true;
}
}