From 6b05c2166cab8c80cbe0abe0032e560659cf502c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=2E=20Rodas?= Date: Fri, 15 Nov 2013 00:26:02 -0300 Subject: [PATCH] added more tests --- tests/DBTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/DBTest.php b/tests/DBTest.php index 90e7cba..b52c953 100644 --- a/tests/DBTest.php +++ b/tests/DBTest.php @@ -87,12 +87,35 @@ class DBTest extends \phpunit_framework_testcase $this->assertEquals($db->first("SELECT mean(karma) FROM foobar")->mean, 20); foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) { + $this->assertTrue(is_int($row->time)); if ($row->type == "/foobar") { $this->assertEquals(15, $row->mean); } else { $this->assertEquals(30, $row->mean); } } + } + + /** @dependsOn testQuery */ + function testDifferentTimePeriod() + { + $client = new Client; + $db = $client->test_xxx; + + $client->setTimePrecision('u'); + foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) { + $this->assertTrue($row->time > time()*1000); + } + + $client->setTimePrecision('m'); + foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) { + $this->assertTrue($row->time < time()*10000); + } + + $client->setTimePrecision('s'); + foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) { + $this->assertTrue($row->time < time()+20); + } $db->drop(); }