mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Remove deprecated policy and visibility scoping events
This commit is contained in:
@@ -118,29 +118,6 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(2, Arr::get($json, 'data.relationships.posts.data.0.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function when_allowed_guests_can_see_hidden_posts()
|
||||
{
|
||||
/** @var Dispatcher $events */
|
||||
$events = $this->app()->getContainer()->make(Dispatcher::class);
|
||||
|
||||
$events->listen(ScopeModelVisibility::class, function (ScopeModelVisibility $event) {
|
||||
if ($event->ability === 'hidePosts') {
|
||||
$event->query->whereRaw('1=1');
|
||||
}
|
||||
});
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions/4')
|
||||
);
|
||||
|
||||
$json = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(2, Arr::get($json, 'data.relationships.posts.data.0.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
@@ -18,6 +18,7 @@ use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Tests\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ModelVisibilityTest extends TestCase
|
||||
{
|
||||
@@ -46,6 +47,27 @@ class ModelVisibilityTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function when_allowed_guests_can_see_hidden_posts()
|
||||
{
|
||||
$this->extend(
|
||||
(new Extend\ModelVisibility(CommentPost::class))
|
||||
->scope(function (User $user, Builder $query) {
|
||||
$query->whereRaw('1=1');
|
||||
}, 'hidePosts')
|
||||
);
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions/2')
|
||||
);
|
||||
|
||||
$json = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(1, Arr::get($json, 'data.relationships.posts.data.0.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
Reference in New Issue
Block a user