mirror of
https://github.com/flarum/core.git
synced 2025-08-10 10:24:46 +02:00
test: list posts with mentions filter and createdAt
sort
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
|||||||
use Flarum\Testing\integration\TestCase;
|
use Flarum\Testing\integration\TestCase;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class ListTest extends TestCase
|
class ListPostsTest extends TestCase
|
||||||
{
|
{
|
||||||
use RetrievesAuthorizedUsers;
|
use RetrievesAuthorizedUsers;
|
||||||
|
|
||||||
@@ -85,4 +85,26 @@ class ListTest extends TestCase
|
|||||||
$ids = Arr::pluck($data, 'id');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['4'], $ids, 'IDs do not match');
|
$this->assertEqualsCanonicalizing(['4'], $ids, 'IDs do not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function mentioned_filter_works_with_sort()
|
||||||
|
{
|
||||||
|
$response = $this->send(
|
||||||
|
$this->request('GET', '/api/posts')
|
||||||
|
->withQueryParams([
|
||||||
|
'filter' => ['mentioned' => 1],
|
||||||
|
'sort' => '-createdAt'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
||||||
|
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
|
// Order-independent comparison
|
||||||
|
$ids = Arr::pluck($data, 'id');
|
||||||
|
$this->assertEqualsCanonicalizing(['2', '3'], $ids, 'IDs do not match');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user