From ae88f2291c4464cbf4d933b9e92af29975e659ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sat, 17 Jun 2017 13:24:21 +0200 Subject: [PATCH] Add tests for overdue state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/unit/Db/CardTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/Db/CardTest.php b/tests/unit/Db/CardTest.php index e9554c370..184c5b569 100644 --- a/tests/unit/Db/CardTest.php +++ b/tests/unit/Db/CardTest.php @@ -23,6 +23,9 @@ namespace OCA\Deck\Db; +use DateInterval; +use DateTime; + class CardTest extends \PHPUnit_Framework_TestCase { private function createCard() { $card = new Card(); @@ -39,6 +42,25 @@ class CardTest extends \PHPUnit_Framework_TestCase { // TODO: relation shared labels acl return $card; } + + public function dataDuedate() { + return [ + [(new DateTime()), Card::DUEDATE_NOW], + [(new DateTime())->sub(new DateInterval('P1D')), Card::DUEDATE_OVERDUE], + [(new DateTime())->add(new DateInterval('P1D')), Card::DUEDATE_NEXT], + [(new DateTime())->add(new DateInterval('P2D')), Card::DUEDATE_FUTURE] + ]; + } + + /** + * @dataProvider dataDuedate + */ + public function testDuedate(DateTime $duedate, $state) { + $card = $this->createCard(); + $card->setDuedate($duedate->format('Y-m-d H:i:s')); + $this->assertEquals($state, $card->jsonSerialize()['overdue']); + } + public function testJsonSerialize() { $card = $this->createCard(); $this->assertEquals([