mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
allow filtering by time when listing demos in api
This commit is contained in:
parent
4c3e219815
commit
0d70d93e13
5 changed files with 82 additions and 3 deletions
|
|
@ -198,4 +198,33 @@ class DemoControllerTest extends ControllerTest {
|
|||
['user' => 'foo2', 'time' => 2, 'message' => 'bar2'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testListFilterTime() {
|
||||
$controller = $this->getController(['before' => '500', 'after' => '100']);
|
||||
|
||||
$this->demoListProvider->expects($this->once())
|
||||
->method('listDemos')
|
||||
->with(1, [
|
||||
'before' => \DateTime::createFromFormat('U', '500'),
|
||||
'after' => \DateTime::createFromFormat('U', '100')
|
||||
], 'DESC')
|
||||
->willReturn(['dummy']);
|
||||
|
||||
$controller->listDemos();
|
||||
$this->assertResponseData(['dummy']);
|
||||
}
|
||||
|
||||
public function testListFilterTimeInvalid() {
|
||||
$controller = $this->getController(['before' => '500', 'after' => 'foobar']);
|
||||
|
||||
$this->demoListProvider->expects($this->once())
|
||||
->method('listDemos')
|
||||
->with(1, [
|
||||
'before' => \DateTime::createFromFormat('U', '500')
|
||||
], 'DESC')
|
||||
->willReturn(['dummy']);
|
||||
|
||||
$controller->listDemos();
|
||||
$this->assertResponseData(['dummy']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue