Skip to content

Commit

Permalink
Converting spaces to tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 29, 2010
1 parent 6527e92 commit 596c751
Showing 1 changed file with 93 additions and 91 deletions.
184 changes: 93 additions & 91 deletions cake/tests/cases/libs/model/model_write.test.php
Expand Up @@ -3689,6 +3689,7 @@ function testSaveAllHasManyValidationOnly() {
);
$this->assertEqual($TestModel->Comment->validationErrors, $expected);
}

/**
* TestFindAllWithoutForeignKey
*
Expand All @@ -3702,65 +3703,66 @@ function testFindAllForeignKey() {

$conditions = array('Group.name' => 'group one');

$ProductUpdateAll->bindModel(array(
$ProductUpdateAll->bindModel(array(
'belongsTo' => array(
'Group' => array('className' => 'GroupUpdateAll')
)
));

$ProductUpdateAll->belongsTo = array(
$ProductUpdateAll->belongsTo = array(
'Group' => array('className' => 'GroupUpdateAll', 'foreignKey' => 'group_id')
);

$results = $ProductUpdateAll->find('all', compact('conditions'));
$results = $ProductUpdateAll->find('all', compact('conditions'));
$this->assertTrue(!empty($results));

$ProductUpdateAll->bindModel(array('belongsTo'=>array('Group')));
$ProductUpdateAll->belongsTo = array(
'Group' => array(
$ProductUpdateAll->bindModel(array('belongsTo'=>array('Group')));
$ProductUpdateAll->belongsTo = array(
'Group' => array(
'className' => 'GroupUpdateAll',
'foreignKey' => false,
'conditions' => 'ProductUpdateAll.groupcode = Group.code'
));

$resultsFkFalse = $ProductUpdateAll->find('all', compact('conditions'));
$this->assertTrue(!empty($resultsFkFalse));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'product one',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'product two',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
)

);
$this->assertEqual($results, $expected);
$this->assertEqual($resultsFkFalse, $expected);
}
$resultsFkFalse = $ProductUpdateAll->find('all', compact('conditions'));
$this->assertTrue(!empty($resultsFkFalse));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'product one',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'product two',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
)

);
$this->assertEqual($results, $expected);
$this->assertEqual($resultsFkFalse, $expected);
}

/**
* testProductUpdateAllWithForeignKey
*
* @link http://code.cakephp.org/tickets/view/69
* @access public
* @return void
*/
function testProductUpdateAll() {
function testProductUpdateAll() {
$this->skipIf(
$this->db->config['driver'] == 'postgres',
'%s Currently, there is no way of doing joins in an update statement in postgresql'
Expand All @@ -3770,39 +3772,39 @@ function testProductUpdateAll() {

$conditions = array('Group.name' => 'group one');

$ProductUpdateAll->bindModel(array('belongsTo' => array(
$ProductUpdateAll->bindModel(array('belongsTo' => array(
'Group' => array('className' => 'GroupUpdateAll')))
);

$ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
$results = $ProductUpdateAll->find('all', array(
$ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
$results = $ProductUpdateAll->find('all', array(
'conditions' => array('ProductUpdateAll.name' => 'new product')
));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)));

$this->assertEqual($results, $expected);
}
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)));

$this->assertEqual($results, $expected);
}

/**
* testProductUpdateAllWithoutForeignKey
Expand Down Expand Up @@ -3833,32 +3835,32 @@ function testProductUpdateAllWithoutForeignKey() {
)
);

$ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
$resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name'=>'new product')));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)));
$this->assertEqual($resultsFkFalse, $expected);
}
$ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
$resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name'=>'new product')));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(
'id' => 1,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)
),
'1' => array(
'ProductUpdateAll' => array(
'id' => 2,
'name' => 'new product',
'groupcode' => 120,
'group_id' => 1),
'Group' => array(
'id' => 1,
'name' => 'group one',
'code' => 120)));
$this->assertEqual($resultsFkFalse, $expected);
}

/**
* test that saveAll behaves like plain save() when suplied empty data
Expand Down

0 comments on commit 596c751

Please sign in to comment.