diff --git a/test/phpunit/Result/ResultSetTest.php b/test/phpunit/Result/ResultSetTest.php index 72572d4..d060954 100644 --- a/test/phpunit/Result/ResultSetTest.php +++ b/test/phpunit/Result/ResultSetTest.php @@ -8,9 +8,9 @@ class ResultSetTest extends TestCase { const FAKE_DATA = [ - ["id" => 1, "name" => "Alice"], - ["id" => 2, "name" => "Bob"], - ["id" => 3, "name" => "Charlie"], + ["id" => 1, "name" => "Alice", "timestamp" => 576264240, "date" => "1988-04-05 17:24"], + ["id" => 2, "name" => "Bob", "timestamp" => 554900700, "date" => "1987-08-02 11:05"], + ["id" => 3, "name" => "Charlie", "timestamp" => 1433548800, "date" => "2015-06-06"], ]; private $fake_data_index = 0; @@ -130,6 +130,13 @@ public function testAsArray() { } } + public function testAsDateTime() { + $resultSet = new ResultSet($this->getStatementMock()); + $row = $resultSet->fetch(); + self::assertEquals("1988-04-05 17:24", $row->getDateTime("date")->format("Y-m-d H:i")); + self::assertEquals("1988-04-05 17:24", $row->getDateTime("timestamp")->format("Y-m-d H:i")); + } + private function getStatementMock():PDOStatement { $statement = $this->createMock(PDOStatement::class); $statement->method("fetch")