Example #1
0
 /**
  * Tests that default types are passed to functions accepting a $types param
  *
  * @return void
  */
 public function testDefaultTypes()
 {
     $query = new Query($this->connection);
     $this->assertEquals([], $query->defaultTypes());
     $types = ['id' => 'integer', 'created' => 'datetime'];
     $this->assertSame($query, $query->defaultTypes($types));
     $this->assertSame($types, $query->defaultTypes());
     $results = $query->select(['id', 'comment'])->from('comments')->where(['created >=' => new \DateTime('2007-03-18 10:55:00')])->execute();
     $expected = [['id' => '6', 'comment' => 'Second Comment for Second Article']];
     $this->assertEquals($expected, $results->fetchAll('assoc'));
     // Now test default can be overridden
     $types = ['created' => 'date'];
     $results = $query->where(['created >=' => new \DateTime('2007-03-18 10:50:00')], $types, true)->execute();
     $this->assertCount(6, $results, 'All 6 rows should match.');
 }