<commit_before><?php
/**
 *
 * PHP 5
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the below copyright notice.
 *
 * @copyright     Copyright 2013, <NAME> (http://frankfoerster.com)
 * @link          http://github.com/frankfoerster/wasabi
 * @package       Wasabi
 * @subpackage    Wasabi.Plugin.Core.Test.Case.Model
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

App::uses('CakeTestCase', 'TestSuite');
App::uses('ClassRegistry', 'Utility');
App::uses('Hash', 'Utility');
App::uses('User', 'Core.Model');

/**
 * @property User $User
 */

class UserTest extends CakeTestCase {

	public $fixtures = array('plugin.core.user', 'plugin.core.group');

	public function setUp() {
		parent::setUp();
		$this->User = ClassRegistry::init('Core.User');
	}

	public function testUserBelongsToGroup() {
		$this->assertTrue(array_key_exists('Group', $this->User->belongsTo));
	}

	public function testUserHasManyLoginToken() {
		$this->assertTrue(array_key_exists('LoginToken', $this->User->hasMany));
		$this->assertTrue(Hash::get($this->User->hasMany, 'LoginToken.dependent'));
	}

	public function testFindAll() {
		$result = $this->User->findAll();
		$expected = array(
			array('User' => array('id' => 1, 'group_id' => 1, 'language_id' => 1, 'username' => 'admin', 'password' => <PASSWORD>', 'active' => 1, 'created' => '2013-01-12 14:00:00', 'modified' => '2013-01-12 14:00:00')),
			array('User' => array('id' => 2, 'group_id' => 1, 'language_id' => 1, 'username' => 'test', 'password' => <PASSWORD>', 'active' => 0, 'created' => '2013-01-12 15:00:00', 'modified' => '2013-01-12 15:00:00'))
		);
		$this->assertEqual($expected, $result);

		$result = $this->User->findAll(array('conditions' => array('id' => 1)));
		$expected = array(
			array('User' => array('id' => 1, 'group_id' => 1, 'language_id' => 1, 'username' => 'admin', 'password' => <PASSWORD>', 'active' => 1, 'created' => '2013-01-12 14:00:00', 'modified' => '2013-01-12 14:00:00'))
		);
		$this->assertEqual($expected, $result);

		$result = $this->User->findAll(array(
			'fields' => array(
				'User.id',
				'Group.*'
			),
			'conditions' => array(
				'User.id' => 1
			),
			'contain' => array(
				'Group'<commit_msg>coding style<commit_after><?php
/**
 *
 * PHP 5
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the below copyright notice.
 *
 * @copyright     Copyright 2013, <NAME> (http://frankfoerster.com)
 * @link          http://github.com/frankfoerster/wasabi
 * @package       Wasabi
 * @subpackage    Wasabi.Plugin.Core.Test.Case.Model
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

App::uses('CakeTestCase', 'TestSuite');
App::uses('ClassRegistry', 'Utility');
App::uses('Hash', 'Utility');
App::uses('User', 'Core.Model');

/**
 * @property User $User
 */

class UserTest extends CakeTestCase {

	public $fixtures = array('plugin.core.user', 'plugin.core.group');

	public function setUp() {
		parent::setUp();
		$this->User = ClassRegistry::init('Core.User');
	}

	public function testUserBelongsToGroup() {
		$this->assertTrue(array_key_exists('Group', $this->User->belongsTo));
	}

	public function testUserHasManyLoginToken() {
		$this->assertTrue(array_key_exists('LoginToken', $this->User->hasMany));
		$this->assertTrue(Hash::get($this->User->hasMany, 'LoginToken.dependent'));
	}

	public function testFindAll() {
		$result = $this->User->findAll();
		$expected = array(
			array(
				'User' => array(
					'id' => 1,
					'group_id' => 1,
					'language_id' => 1,
					'username' => 'admin',
					'password' => <PASSWORD>',
					'active' => 1,
					'created' => '2013-01-12 14:00:00',
					'modified' => '2013-01-12 14:00:00'
				)
			),
			array(
				'User' => array(
					'id' => 2,
					'group_id' => 1,
					'language_id' => 1,
					'username' => 'test',
					'password' => <PASSWORD>',
					'active' => 0,
					'created' => '2013-01-12 15:00:00',
					'modified' => '2013-01-12 15:00:00'
				)
			)
		);
		$this->assertEqual($expected, $result);

		$result = $this->User->findAll(array('conditions' => array('id' => 1)));
		$expected = array(
			array('User' => array('id' => 1, 'group_id' => 1, 'language_id' => 1, 'username' => 'admin', 'password' => <PASSWORD>', 'active' => 1, 'created' => '2013-01-12 14:00:00', 'modified' => '2013-01-12 14:00:00'))
		);
		$this->assertEqual($expected, $result);

		$result = $this->User->findAll(array(
			'fields' => array(
				'User.id',
				'Group.*'
			),
			'conditions' => array(
				'User.id' => 1
			),
			'contain' => array(
				'Group'
{'fraction_non_alphanumeric': 0.21683618264444926, 'fraction_numerical': 0.04457909543388877, 'mean_word_length': 3.8858350951374208, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237525', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1618, 'n_words': 316}