Skip to content

Commit

Permalink
Add test for the 'contain' setting, which was missing (unrelated to f…
Browse files Browse the repository at this point in the history
…eature)
  • Loading branch information
sebastienbarre committed Oct 31, 2014
1 parent 2f62ee2 commit f6c7102
Showing 1 changed file with 30 additions and 1 deletion.
Expand Up @@ -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
Expand Down Expand Up @@ -197,6 +197,35 @@ public function testAuthenticateSuccess() {
$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
*
Expand Down

0 comments on commit f6c7102

Please sign in to comment.