1
0
Fork 0
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:
Robin Appelman 2020-11-25 23:04:49 +01:00
commit 0d70d93e13
5 changed files with 82 additions and 3 deletions

View file

@ -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']);
}
}