2019-07-17 20:08:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
|
|
|
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
|
|
|
* @author Keyboard Monkey Ltd
|
|
|
|
* @since CommunityID 0.9
|
|
|
|
* @package CommunityID
|
|
|
|
* @packager Keyboard Monkeys
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/../../../TestHarness.php';
|
|
|
|
|
|
|
|
class IdentityControllerTests extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
private $_response;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
TestHarness::setUp();
|
2019-07-17 20:16:19 +00:00
|
|
|
Application::$front->returnResponse(true);
|
2019-07-17 20:08:50 +00:00
|
|
|
$this->_response = new Zend_Controller_Response_Http();
|
2019-07-17 20:16:19 +00:00
|
|
|
Application::$front->setResponse($this->_response);
|
2019-07-17 20:08:50 +00:00
|
|
|
|
|
|
|
// guest user
|
2019-07-17 20:16:19 +00:00
|
|
|
$users = new Users_Model_Users();
|
2019-07-17 20:08:50 +00:00
|
|
|
$user = $users->createRow();
|
|
|
|
Zend_Registry::set('user', $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIndexNoIdentityAction()
|
|
|
|
{
|
2019-07-17 20:16:19 +00:00
|
|
|
Application::$front->setRequest(new TestRequest('/identity'));
|
2019-07-17 20:19:00 +00:00
|
|
|
try {
|
|
|
|
Application::dispatch();
|
|
|
|
} catch (Monkeys_BadUrlException $e) {
|
|
|
|
$this->assertTrue(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->fail('Expected Monkeys_BadUrlException was not raised');
|
2019-07-17 20:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIdAction()
|
|
|
|
{
|
2019-07-17 20:16:19 +00:00
|
|
|
Application::$front->setRequest(new TestRequest('/identity/whateva'));
|
2019-07-17 20:08:50 +00:00
|
|
|
$_SERVER['SCRIPT_URI'] = 'http://localhost/communityid/identity/whateva';
|
2019-07-17 20:16:19 +00:00
|
|
|
Application::dispatch();
|
2019-07-17 20:08:50 +00:00
|
|
|
$this->assertContains('<link href="http://localhost/communityid/openid/provider" rel="openid2.provider" />',
|
|
|
|
$this->_response->getBody());
|
|
|
|
$this->assertContains('<h2 style="text-align:center">http://localhost/communityid/identity/whateva</h2>',
|
|
|
|
$this->_response->getBody());
|
|
|
|
}
|
|
|
|
}
|