mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Add test for the 'contain' setting, which was missing (unrelated to feature)
This commit is contained in:
parent
2f62ee2cde
commit
f6c71024c5
1 changed files with 30 additions and 1 deletions
|
@ -36,7 +36,7 @@ class BasicAuthenticateTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $fixtures = array('core.user', 'core.auth_user');
|
public $fixtures = array('core.user', 'core.auth_user', 'core.article');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup
|
* setup
|
||||||
|
@ -197,6 +197,35 @@ class BasicAuthenticateTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test contain success
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAuthenticateContainSuccess() {
|
||||||
|
$User = ClassRegistry::init('User');
|
||||||
|
$User->bindModel(array('hasMany' => array('Article')));
|
||||||
|
$User->Behaviors->load('Containable');
|
||||||
|
$this->auth->settings['contain'] = 'Article';
|
||||||
|
$request = new CakeRequest('posts/index', false);
|
||||||
|
$request->addParams(array('pass' => array(), 'named' => array()));
|
||||||
|
|
||||||
|
$_SERVER['PHP_AUTH_USER'] = 'mariano';
|
||||||
|
$_SERVER['PHP_AUTH_PW'] = 'password';
|
||||||
|
|
||||||
|
$result = $this->auth->authenticate($request, $this->response);
|
||||||
|
$expected = array(
|
||||||
|
'id' => 1,
|
||||||
|
'user_id' => 1,
|
||||||
|
'title' => 'First Article',
|
||||||
|
'body' => 'First Article Body',
|
||||||
|
'published' => 'Y',
|
||||||
|
'created' => '2007-03-18 10:39:23',
|
||||||
|
'updated' => '2007-03-18 10:41:31'
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result['Article'][0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test userFields success
|
* test userFields success
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue