mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Added tests to cover API config and listing code
This commit is contained in:
47
tests/Api/ApiConfigTest.php
Normal file
47
tests/Api/ApiConfigTest.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use BookStack\Auth\Permissions\RolePermission;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApiAuthTest extends TestCase
|
||||
{
|
||||
use TestsApi;
|
||||
|
||||
protected $endpoint = '/api/books';
|
||||
|
||||
public function test_default_item_count_reflected_in_listing_requests()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
|
||||
config()->set(['api.default_item_count' => 5]);
|
||||
$resp = $this->get($this->endpoint);
|
||||
$resp->assertJsonCount(5, 'data');
|
||||
|
||||
config()->set(['api.default_item_count' => 1]);
|
||||
$resp = $this->get($this->endpoint);
|
||||
$resp->assertJsonCount(1, 'data');
|
||||
}
|
||||
|
||||
public function test_default_item_count_does_not_limit_count_param()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
config()->set(['api.default_item_count' => 1]);
|
||||
$resp = $this->get($this->endpoint . '?count=5');
|
||||
$resp->assertJsonCount(5, 'data');
|
||||
}
|
||||
|
||||
public function test_max_item_count_limits_listing_requests()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
|
||||
config()->set(['api.max_item_count' => 2]);
|
||||
$resp = $this->get($this->endpoint);
|
||||
$resp->assertJsonCount(2, 'data');
|
||||
|
||||
$resp = $this->get($this->endpoint . '?count=5');
|
||||
$resp->assertJsonCount(2, 'data');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user