mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Removing pagination test from Containable test case, it doesn't make sense there.
This commit is contained in:
parent
5df2678ba9
commit
51e2b16d46
1 changed files with 0 additions and 106 deletions
|
@ -3191,112 +3191,6 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testPaginate method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testPaginate() {
|
||||
App::import('Core', 'Controller');
|
||||
$Controller = new Controller($this->getMock('CakeRequest'));
|
||||
$Controller->uses = array('Article');
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->request->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$Controller->paginate = array('Article' => array('fields' => array('title'), 'contain' => array('User(user)')));
|
||||
$result = $Controller->paginate('Article');
|
||||
$expected = array(
|
||||
array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
|
||||
array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)),
|
||||
array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$r = $Controller->Article->find('all');
|
||||
$this->assertTrue(Set::matches('/Article[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/User[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/Tag[id=1]', $r));
|
||||
|
||||
$Controller->paginate = array('Article' => array('contain' => array('Comment(comment)' => 'User(user)'), 'fields' => array('title')));
|
||||
$result = $Controller->paginate('Article');
|
||||
$expected = array(
|
||||
array(
|
||||
'Article' => array('title' => 'First Article', 'id' => 1),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'comment' => 'First Comment for First Article',
|
||||
'user_id' => 2,
|
||||
'article_id' => 1,
|
||||
'User' => array('user' => 'nate')
|
||||
),
|
||||
array(
|
||||
'comment' => 'Second Comment for First Article',
|
||||
'user_id' => 4,
|
||||
'article_id' => 1,
|
||||
'User' => array('user' => 'garrett')
|
||||
),
|
||||
array(
|
||||
'comment' => 'Third Comment for First Article',
|
||||
'user_id' => 1,
|
||||
'article_id' => 1,
|
||||
'User' => array('user' => 'mariano')
|
||||
),
|
||||
array(
|
||||
'comment' => 'Fourth Comment for First Article',
|
||||
'user_id' => 1,
|
||||
'article_id' => 1,
|
||||
'User' => array('user' => 'mariano')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Article' => array('title' => 'Second Article', 'id' => 2),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'comment' => 'First Comment for Second Article',
|
||||
'user_id' => 1,
|
||||
'article_id' => 2,
|
||||
'User' => array('user' => 'mariano')
|
||||
),
|
||||
array(
|
||||
'comment' => 'Second Comment for Second Article',
|
||||
'user_id' => 2,
|
||||
'article_id' => 2,
|
||||
'User' => array('user' => 'nate')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Article' => array('title' => 'Third Article', 'id' => 3),
|
||||
'Comment' => array()
|
||||
),
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$r = $Controller->Article->find('all');
|
||||
$this->assertTrue(Set::matches('/Article[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/User[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/Tag[id=1]', $r));
|
||||
|
||||
$Controller->Article->unbindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User'), 'hasAndBelongsToMany' => array('Tag')), false);
|
||||
$Controller->Article->bindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User')), false);
|
||||
|
||||
$Controller->paginate = array('Article' => array('contain' => array('Comment(comment)', 'User(user)'), 'fields' => array('title')));
|
||||
$r = $Controller->paginate('Article');
|
||||
$this->assertTrue(Set::matches('/Article[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/User[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/Comment[article_id=1]', $r));
|
||||
$this->assertFalse(Set::matches('/Comment[id=1]', $r));
|
||||
|
||||
$r = $this->Article->find('all');
|
||||
$this->assertTrue(Set::matches('/Article[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/User[id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/Comment[article_id=1]', $r));
|
||||
$this->assertTrue(Set::matches('/Comment[id=1]', $r));
|
||||
}
|
||||
|
||||
/**
|
||||
* testOriginalAssociations method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue