mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-10 05:22:41 +00:00
Added accidentally removed tests back in.
This commit is contained in:
parent
1b704fb7cf
commit
a77e46cbfd
1 changed files with 71 additions and 2 deletions
|
@ -166,10 +166,10 @@ class DboSourceTest extends CakeTestCase {
|
|||
*/
|
||||
public function testBooleanEmptyConditionsParsing() {
|
||||
$result = $this->testDb->conditions(array('OR' => array()));
|
||||
$this->assertEquals(' WHERE 1 = 1', $result, 'empty conditions failed %s');
|
||||
$this->assertEquals(' WHERE 1 = 1', $result, 'empty conditions failed');
|
||||
|
||||
$result = $this->testDb->conditions(array('OR' => array('OR' => array())));
|
||||
$this->assertEquals(' WHERE 1 = 1', $result, 'nested empty conditions failed %s');
|
||||
$this->assertEquals(' WHERE 1 = 1', $result, 'nested empty conditions failed');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1116,4 +1116,73 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test conditionKeysToString()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConditionKeysToString() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$conn = $this->getMock('MockPDO', array('quote'));
|
||||
$db = new DboTestSource;
|
||||
$db->setConnection($conn);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
|
||||
$conditions = array('Article.name' => 'just text');
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "Article.name = just text";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
$conn->expects($this->at(1))
|
||||
->method('quote')
|
||||
->will($this->returnValue('other text'));
|
||||
|
||||
$conditions = array('Article.name' => array('just text', 'other text'));
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "Article.name IN (just text, other text)";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test conditionKeysToString() with virtual field
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConditionKeysToStringVirtualField() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$Article->virtualFields = array(
|
||||
'extra' => 'something virtual'
|
||||
);
|
||||
$conn = $this->getMock('MockPDO', array('quote'));
|
||||
$db = new DboTestSource;
|
||||
$db->setConnection($conn);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
|
||||
$conditions = array('Article.extra' => 'just text');
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "(" . $Article->virtualFields['extra'] . ") = just text";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
$conn->expects($this->at(1))
|
||||
->method('quote')
|
||||
->will($this->returnValue('other text'));
|
||||
|
||||
$conditions = array('Article.extra' => array('just text', 'other text'));
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "(" . $Article->virtualFields['extra'] . ") IN (just text, other text)";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue