mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Add deprecated "user" filter for posts
In the filterer refactor for ListPostsController, the filter key was changed to `author` for consistency with the AuthorFilterGambit used in discussions. This commit adds a deprecated `user` filter back in for a release to allow for a graceful transition
This commit is contained in:
@@ -114,6 +114,44 @@ class ListTests extends TestCase
|
||||
$this->assertEquals(['1', '2', '3', '4', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @deprecated
|
||||
*/
|
||||
public function user_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts', ['authenticatedAs' => 1])
|
||||
->withQueryParams([
|
||||
'filter' => ['user' => 'admin'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(['1', '2'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @deprecated
|
||||
*/
|
||||
public function user_filter_works_with_multiple_values()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts', ['authenticatedAs' => 1])
|
||||
->withQueryParams([
|
||||
'filter' => ['user' => 'admin,normal'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(['1', '2', '3', '4', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
Reference in New Issue
Block a user