added more tests

This commit is contained in:
César D. Rodas 2013-11-15 00:26:02 -03:00
parent fd9667d928
commit 6b05c2166c

View File

@ -87,12 +87,35 @@ class DBTest extends \phpunit_framework_testcase
$this->assertEquals($db->first("SELECT mean(karma) FROM foobar")->mean, 20); $this->assertEquals($db->first("SELECT mean(karma) FROM foobar")->mean, 20);
foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) { foreach ($db->query("SELECT mean(karma) FROM foobar GROUP BY type") as $row) {
$this->assertTrue(is_int($row->time));
if ($row->type == "/foobar") { if ($row->type == "/foobar") {
$this->assertEquals(15, $row->mean); $this->assertEquals(15, $row->mean);
} else { } else {
$this->assertEquals(30, $row->mean); $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(); $db->drop();
} }