本文整理汇总了PHP中JSession::getToken方法的典型用法代码示例。如果您正苦于以下问题:PHP JSession::getToken方法的具体用法?PHP JSession::getToken怎么用?PHP JSession::getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSession
的用法示例。
在下文中一共展示了JSession::getToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetFormToken
/**
* Test...
*
* @covers JSession::getFormToken
*
* @return void
*/
public function testGetFormToken()
{
$user = JFactory::getUser();
JFactory::$application = $this->getMock('JInputCookie', array('set', 'get'));
JFactory::$application->expects($this->once())->method('get')->with($this->equalTo('secret'))->will($this->returnValue('abc'));
$expected = md5('abc' . $user->get('id', 0) . $this->object->getToken(false));
$this->assertEquals($expected, $this->object->getFormToken(), 'Form token should be calculated as above');
}
示例2: testGetFormToken
/**
* Test getFormToken
*
* @covers JSession::getFormToken
*
* @return void
*/
public function testGetFormToken()
{
// Set the factory session object for getting the token
JFactory::$session = $this->object;
$user = JFactory::getUser();
$expected = md5($user->get('id', 0) . $this->object->getToken(false));
$this->assertEquals($expected, $this->object->getFormToken(false), 'Form token should be calculated as above.');
}
示例3: testHasToken
/**
* Test hasToken
*
* @covers JSession::hasToken
*
* @return void
*/
public function testHasToken()
{
$token = $this->object->getToken();
$this->assertTrue($this->object->hasToken($token), 'Line: ' . __LINE__ . ' Correct token should be true');
$this->assertFalse($this->object->hasToken('abc', false), 'Line: ' . __LINE__ . ' Should return false with wrong token');
$this->assertEquals('active', $this->object->getState(), 'Line: ' . __LINE__ . ' State should not be set to expired');
$this->assertFalse($this->object->hasToken('abc'), 'Line: ' . __LINE__ . ' Should return false with wrong token');
$this->assertEquals('expired', $this->object->getState(), 'Line: ' . __LINE__ . ' State should be set to expired by default');
}