+ // Random numbers should have been ordered from least to greatest
+ $this->assertGreaterThanOrEqual($result[0]['rand'], $result[1]['rand']);
+ $this->assertGreaterThanOrEqual($result[1]['rand'], $result[2]['rand']);
+ $this->assertGreaterThanOrEqual($result[2]['rand'], $result[3]['rand']);
+ $this->assertGreaterThanOrEqual($result[3]['rand'], $result[4]['rand']);
+ $this->assertGreaterThanOrEqual($result[4]['rand'], $result[5]['rand']);
+ }
+
+ public function testDateInWhereClause() {
+ $lastName = uniqid(__FUNCTION__);
+ $sampleData = [
+ ['first_name' => 'abc', 'last_name' => $lastName, 'birth_date' => '2009-11-11'],
+ ['first_name' => 'def', 'last_name' => $lastName, 'birth_date' => '2009-01-01'],
+ ['first_name' => 'def', 'last_name' => $lastName, 'birth_date' => '2010-01-01'],
+ ];
+ Contact::save(FALSE)
+ ->setRecords($sampleData)
+ ->execute();
+
+ // Should work with isExpression=FALSE
+ $result = Contact::get(FALSE)
+ ->addWhere('last_name', '=', $lastName)
+ ->addWhere('YEAR(birth_date)', '=', 2009)
+ ->selectRowCount()
+ ->execute();
+ $this->assertCount(2, $result);
+
+ // Should work with isExpression=TRUE
+ $result = Contact::get(FALSE)
+ ->addWhere('last_name', '=', $lastName)
+ ->addWhere('YEAR(birth_date)', '=', 2009, TRUE)
+ ->selectRowCount()
+ ->execute();
+ $this->assertCount(2, $result);
+
+ // Try an expression in the value
+ $result = Contact::get(FALSE)
+ ->addWhere('last_name', '=', $lastName)
+ ->addWhere('MONTH(birth_date)', '=', 'MONTH("2030-11-12")', TRUE)
+ ->addSelect('birth_date')
+ ->execute()->single();
+ $this->assertEquals('2009-11-11', $result['birth_date']);