Add test for the 'contain' setting, which was missing (unrelated to feature)

This commit is contained in:
Sebastien Barre 2014-10-31 16:04:09 -04:00
parent 2f62ee2cde
commit f6c71024c5

View file

@ -36,7 +36,7 @@ class BasicAuthenticateTest extends CakeTestCase {
*
* @var array
*/
public $fixtures = array('core.user', 'core.auth_user');
public $fixtures = array('core.user', 'core.auth_user', 'core.article');
/**
* setup
@ -197,6 +197,35 @@ class BasicAuthenticateTest extends CakeTestCase {
$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
*