<commit_before><?php

/**
 * test TwimUser
 *
 * PHP versions 5
 *
 * Copyright 2011, nojimage (http://php-tips.com/)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @version   1.0
 * @author    nojimage <nojimage at gmail.com>
 * @copyright 2011 nojimage (http://php-tips.com/)
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link    　http://php-tips.com/
 * @since   　File available since Release 1.0
 *
 */
App::uses('TwimConnectionTestCase', 'Twim.TestSuite');

/**
 *
 * @property TwimUser $User
 */
class TwimUserTestCase extends TwimConnectionTestCase {

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

	public function tearDown() {
		unset($this->User);
		parent::tearDown();
	}

	// =========================================================================

	public function testLookup() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->assertFalse($this->User->find('lookup'));
	}

	public function testLookup_user_id() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('user_id' => '1234'));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('user_id' => '1234'));
	}

	public function testLookup_array_user_id() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('user_id' => array('1234', '5678', '9876')));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('user_id' => '1234,5678,9876'));
	}

	public function testLookup_screen_name() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('screen_name' => 'abcd'));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('screen_name' => 'abcd'));
	}

	public function testLookup_array_screen_name() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('screen_name' => array('abcd', 'efgh', 'ijkl')));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('screen_name' => 'abcd,efgh,ijkl'));
	}

	public function testLookup_real_by_screen_name() {
		$this->User->setDataSource('twitter');
		$results = $this->User->find('lookup', array('screen_name' => array('cakephp', 'nojimage')));
		$screenNames = Set::extract('/screen_name', $results);
		$ids = Set::extract('/id_str', $results);
		$this->assertEqual(array('cakephp', 'nojimage'), $screenNames);
		$this->assertEqual(array('8620662', '15982041'), $ids);
	}

	public function testLookup_real_by_user_id() {
		$this->User->setDataSource('twitter');
		$results = $this->User->find('lookup', array('user_id' => array('8620662', '15982041')));<commit_msg>fixes TwimUserTest<commit_after><?php

/**
 * test TwimUser
 *
 * PHP versions 5
 *
 * Copyright 2011, nojimage (http://php-tips.com/)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @version   1.0
 * @author    nojimage <<EMAIL>>
 * @copyright 2011 nojimage (http://php-tips.com/)
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link    　http://php-tips.com/
 * @since   　File available since Release 1.0
 *
 */
App::uses('TwimConnectionTestCase', 'Twim.TestSuite');

/**
 *
 * @property TwimUser $User
 */
class TwimUserTestCase extends TwimConnectionTestCase {

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

	public function tearDown() {
		unset($this->User);
		parent::tearDown();
	}

	// =========================================================================

	public function testLookup() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->assertFalse($this->User->find('lookup'));
	}

	public function testLookup_user_id() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('user_id' => '1234'));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('user_id' => '1234'));
	}

	public function testLookup_array_user_id() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('user_id' => array('1234', '5678', '9876')));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('user_id' => '1234,5678,9876'));
	}

	public function testLookup_screen_name() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('screen_name' => 'abcd'));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('screen_name' => 'abcd'));
	}

	public function testLookup_array_screen_name() {
		$this->User->getDataSource()->expects($this->once())->method('request')->will($this->returnValue(false));
		$this->User->find('lookup', array('screen_name' => array('abcd', 'efgh', 'ijkl')));
		$this->assertIdentical($this->User->request['uri']['path'], '1/users/lookup');
		$this->assertIdentical($this->User->request['uri']['query'], array('screen_name' => 'abcd,efgh,ijkl'));
	}

	public function testLookup_real_by_screen_name() {
		$this->User->setDataSource('twitter');
		$results = $this->User->find('lookup', array('screen_name' => array('cakephp', 'nojimage')));
		$results = Set::sort($results, '/id_str', 'asc');
		$screenNames = Set::extract('/screen_name', $results);
		$ids = Set::extract('/id_str', $results);
		$this->assertEqual(array('cakephp', 'nojimage'), $screenNames);
		$this->assertEqual(array('8620662', '15982041'), $ids);
	}

	public function testLookup_real_by_user_id() {
		$this->User->setDataSource('twitter');
		$results = $this->User->find('lookup', array('user_id' => array('8620662', '15982041')));
		$results = Set::sort($results, '/id_str', 'asc');
{'fraction_non_alphanumeric': 0.24745373691005595, 'fraction_numerical': 0.022665327786544256, 'mean_word_length': 6.285266457680251, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 196, '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': '6623577', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2225, 'n_words': 320}