Skip to content

Commit

Permalink
Fix failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 14, 2011
1 parent 07a2a60 commit cfb6ed4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -3485,18 +3485,21 @@ public function testExceptionOnBrokenConnection() {
public function testUpdateStatements() {
$this->loadFixtures('Article', 'User');
$test = ConnectionManager::getDatasource('test');
$db = $test->config['database'];

$this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));

$this->Dbo->expects($this->at(0))->method('execute')
->with("UPDATE `articles` SET `field1` = 'value1' WHERE 1 = 1");
->with("UPDATE `$db`.`articles` SET `field1` = 'value1' WHERE 1 = 1");

$this->Dbo->expects($this->at(1))->method('execute')
->with("UPDATE `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" .
->with("UPDATE `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` ON " .
"(`Article`.`user_id` = `User`.`id`)" .
" SET `Article`.`field1` = 2 WHERE 2=2");

$this->Dbo->expects($this->at(2))->method('execute')
->with("UPDATE `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" .
->with("UPDATE `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` ON " .
"(`Article`.`user_id` = `User`.`id`)" .
" SET `Article`.`field1` = 'value' WHERE `index` = 'val'");

$Article = new Article();
Expand All @@ -3515,18 +3518,21 @@ public function testUpdateStatements() {
public function testDeleteStatements() {
$this->loadFixtures('Article', 'User');
$test = ConnectionManager::getDatasource('test');
$db = $test->config['database'];

$this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));

$this->Dbo->expects($this->at(0))->method('execute')
->with("DELETE FROM `articles` WHERE 1 = 1");
->with("DELETE FROM `$db`.`articles` WHERE 1 = 1");

$this->Dbo->expects($this->at(1))->method('execute')
->with("DELETE `Article` FROM `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" .
->with("DELETE `Article` FROM `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` " .
"ON (`Article`.`user_id` = `User`.`id`)" .
" WHERE 1 = 1");

$this->Dbo->expects($this->at(2))->method('execute')
->with("DELETE `Article` FROM `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" .
->with("DELETE `Article` FROM `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` " .
"ON (`Article`.`user_id` = `User`.`id`)" .
" WHERE 2=2");
$Article = new Article();

Expand Down

0 comments on commit cfb6ed4

Please sign in to comment.