mirror of
https://github.com/flarum/framework.git
synced 2025-01-31 22:16:32 +08:00
parent
7143e13073
commit
8b808bfc85
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user