Add a test for viewUserList guest permission

This test would have failed without commit ea84fc4. Next, I will revert
that commit and most of my PR #1854, so we need this test to ensure the
API continues to behave as desired.
This commit is contained in:
Franz Liedke 2019-09-14 21:23:30 +02:00 committed by Daniël Klabbers
parent 04b2cf4462
commit ab0ba707e7

View File

@ -9,6 +9,7 @@
namespace Flarum\Tests\integration\api\users;
use Flarum\Group\Permission;
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
use Flarum\Tests\integration\TestCase;
@ -26,7 +27,9 @@ class ListTest extends TestCase
],
'groups' => [
$this->adminGroup(),
$this->guestGroup(),
],
'group_permission' => [],
'group_user' => [
['user_id' => 1, 'group_id' => 1],
],
@ -48,6 +51,25 @@ class ListTest extends TestCase
$this->assertEquals(401, $response->getStatusCode());
}
/**
* @test
*/
public function shows_index_for_guest_when_they_have_permission()
{
Permission::unguarded(function () {
Permission::create([
'permission' => 'viewUserList',
'group_id' => 2,
]);
});
$response = $this->send(
$this->request('GET', '/api/users')
);
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/