mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding test to show afterFind being called from Model::find('list'), closes #4456
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6684 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
5f967487bb
commit
5f8641aac9
2 changed files with 22 additions and 1 deletions
|
@ -37,7 +37,6 @@ require_once dirname(__FILE__) . DS . 'models.php';
|
|||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class ModelTest extends CakeTestCase {
|
||||
|
||||
var $autoFixtures = false;
|
||||
|
||||
var $fixtures = array(
|
||||
|
@ -752,6 +751,7 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
function testGenerateList() {
|
||||
$this->loadFixtures('Article', 'Apple', 'Post', 'Author', 'User');
|
||||
|
||||
$this->model =& new Article();
|
||||
$this->model->displayField = 'title';
|
||||
|
||||
|
@ -808,6 +808,11 @@ class ModelTest extends CakeTestCase {
|
|||
$result = $this->model->find('list', array('fields' => array('User.user', 'User.password')));
|
||||
$expected = array('mariano' => '5f4dcc3b5aa765d61d8327deb882cf99', 'nate' => '5f4dcc3b5aa765d61d8327deb882cf99', 'larry' => '5f4dcc3b5aa765d61d8327deb882cf99', 'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->model =& new ModifiedAuthor();
|
||||
$result = $this->model->find('list', array('fields' => array('Author.id', 'Author.user')));
|
||||
$expected = array(1 => 'mariano (CakePHP)', 2 => 'nate (CakePHP)', 3 => 'larry (CakePHP)', 4 => 'garrett (CakePHP)');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testRecordExists() {
|
||||
|
|
|
@ -289,6 +289,22 @@ class Author extends CakeTestModel {
|
|||
return $results;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class ModifiedAuthor extends Author {
|
||||
var $name = 'Author';
|
||||
|
||||
function afterFind($results) {
|
||||
foreach($results as $index => $result) {
|
||||
$results[$index]['Author']['user'] .= ' (CakePHP)';
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue