Ejemplo n.º 1
0
	/**
	 * Testing authorize().
	 *
	 * @param	int		User id of user to test
	 * @param	string	Action to get aithorized for this user
	 * @param	string	Asset to get authorization for
	 * @param	bool	Expected return from the authorization check
	 *
	 * @return void
	 */
	public function testAuthorize( )
	{
		// Set up user 99 to be root_user from configuration
		$testConfig = $this->getMock('JConfig', array('get'));
		$testConfig->expects(
			$this->any())
			->method('get')
			->will($this->returnValue('test_root_user'));
		JFactory::$config = $testConfig;
		$user = new JUser(99);
		$user->username = '******';
		$this->assertThat(
			$user->authorize('core.admin', 'root.1'),
			$this->equalTo(true),
			"Emergency root user should have core.admin for root.1"
		);

	}