Permalink
Browse files

Added "like" and "or", and "and" operator tests to DatabaseTests.php

Fixed Auth Form Tests
  • Loading branch information...
1 parent be64119 commit 712214ad2b32c04b5178e73be78e7ac0818f8f0d unknown committed with nateabele Jan 25, 2011
@@ -426,6 +426,32 @@ public function testQueryOperators() {
));
$sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE {$conditions};";
$this->assertEqual($sql, $this->db->renderCommand($query));
+
+ $query = new Query(array(
+ 'type' => 'read', 'model' => $this->_model,
+ 'conditions' => array(
+ 'field' => array('like' => '%value%')
+ )
+ ));
+ $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE ({field} like '%value%');";
+ $this->assertEqual($sql, $this->db->renderCommand($query));
+
+ $query = new Query(array(
+ 'type' => 'read', 'model' => $this->_model,
+ 'conditions' => array(
+ 'or' => array(
+ 'field1' => 'value1',
+ 'field2' => 'value2',
+ 'and' => array(
+ 'sField' => '1',
+ 'sField2' => '2'
+ )
+ ),
+ 'bField' => '3'
+ )
+ ));
+ $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE ({field1} = 'value1' OR {field2} = 'value2' OR ({sField} = 1 AND {sField2} = 2)) AND {bField} = 3;";
+ $this->assertEqual($sql, $this->db->renderCommand($query));
}
public function testRawConditions() {
@@ -24,7 +24,9 @@ public function testLogin() {
$request->data = array('username' => 'Person', 'password' => 'password');
$result = $subject->check($request);
- $expected = array('username' => 'Person', 'password' => sha1('password'));
+ $expected = array('username' => 'Person',
+ 'password' => 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'.
+ '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86');
$this->assertEqual($expected, $result);
}
@@ -36,7 +38,9 @@ public function testLoginWithFilters() {
$request->data = array('username' => 'Person', 'password' => 'password');
$result = $subject->check($request);
- $expected = array('username' => sha1('Person'), 'password' => sha1('password'));
+ $expected = array('username' => sha1('Person'),
+ 'password' => 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'.
+ '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86');
$this->assertEqual($expected, $result);
}

0 comments on commit 712214a

Please sign in to comment.