import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -19,15 +19,15 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
public function setUp()
{
TestHarness::setUp();
Setup::$front->returnResponse(true);
Application::$front->returnResponse(true);
$this->_response = new Zend_Controller_Response_Http();
Setup::$front->setResponse($this->_response);
Application::$front->setResponse($this->_response);
}
public function testIndexAction()
{
Setup::$front->setRequest(new TestRequest('/feedback'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/feedback'));
Application::dispatch();
$this->assertContains('<form id="feedbackForm" method="post" action', $this->_response->getBody());
}
@ -43,10 +43,10 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
'feedback' => $feedback,
);
Setup::$front->setRequest(new TestRequest('/feedback/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/feedback/send'));
Application::dispatch();
$this->assertContains('Value is empty, but a non-empty value is required', $this->_response->getBody());
$this->assertContains('Value is required and can\'t be empty', $this->_response->getBody());
}
public function testSendWithBadEmailAction()
@ -57,8 +57,8 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
'feedback' => 'whateva',
);
Setup::$front->setRequest(new TestRequest('/feedback/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/feedback/send'));
Application::dispatch();
$this->assertContains('is not a valid email address', $this->_response->getBody());
}
@ -72,8 +72,8 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
'captcha' => 'whatever',
);
Setup::$front->setRequest(new TestRequest('/feedback/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/feedback/send'));
Application::dispatch();
$this->assertContains('Captcha value is wrong', $this->_response->getBody());
}
@ -83,8 +83,8 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
// I gotta render the form first to generate the captcha
$sessionStub = new CaptchaImageTestSessionContainer();
Zend_Registry::set('appSession', $sessionStub);
Setup::$front->setRequest(new TestRequest('/feedback/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/feedback/send'));
Application::dispatch();
$this->assertEquals(preg_match('/name="captcha\[id\]" value="([0-9a-f]+)"/', $this->_response->__toString(), $matches), 1);
$email = 'john_' . rand(0, 1000) . '@mailinator.com';
@ -98,15 +98,15 @@ class FeedbackControllerTests extends PHPUnit_Framework_TestCase
)
);
Setup::$front->setRequest(new TestRequest('/feedback/send'));
Application::$front->setRequest(new TestRequest('/feedback/send'));
Setup::$mockLogger->events = array();
Application::$mockLogger->events = array();
try {
Setup::dispatch();
Application::dispatch();
} catch (Zend_Controller_Response_Exception $e) {
// I still don't know how to avoid the "headers already sent" problem here...
}
$lastLog = array_pop(Setup::$mockLogger->events);
$lastLog = array_pop(Application::$mockLogger->events);
$this->assertEquals("redirected to ''", $lastLog['message']);
}

View File

@ -18,14 +18,14 @@ class HistoryControllerTests extends PHPUnit_Framework_TestCase
public function setUp()
{
TestHarness::setUp();
Setup::$front->returnResponse(true);
Application::$front->returnResponse(true);
$this->_response = new Zend_Controller_Response_Http();
Setup::$front->setResponse($this->_response);
Application::$front->setResponse($this->_response);
$users = new Users();
$users = new Users_Model_Users();
$user = $users->createRow();
$user->id = 23;
$user->role = User::ROLE_ADMIN;
$user->role = Users_Model_User::ROLE_ADMIN;
$user->username = 'testuser';
Zend_Registry::set('user', $user);
}
@ -35,16 +35,16 @@ class HistoryControllerTests extends PHPUnit_Framework_TestCase
*/
public function testIndexGuestUserAction()
{
Zend_Registry::get('user')->role = User::ROLE_GUEST;
Zend_Registry::get('user')->role = Users_Model_User::ROLE_GUEST;
Setup::$front->setRequest(new TestRequest('/history'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/history'));
Application::dispatch();
}
public function testIndexAction()
{
Setup::$front->setRequest(new TestRequest('/history'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/history'));
Application::dispatch();
$this->assertContains('COMMID.history', $this->_response->getBody());
}
@ -53,8 +53,8 @@ class HistoryControllerTests extends PHPUnit_Framework_TestCase
{
$request = new TestRequest('/history/list?startIndex=0&results=15');
$request->setHeader('X_REQUESTED_WITH', 'XMLHttpRequest');
Setup::$front->setRequest($request);
Setup::dispatch();
Application::$front->setRequest($request);
Application::dispatch();
$this->assertRegExp(
'#\{("__className":"stdClass",)?"recordsReturned":\d+,"totalRecords":\d+,"startIndex":"\d+",("sort":null,)?"dir":"asc","records":\[.*\]\}#',
@ -69,8 +69,8 @@ class HistoryControllerTests extends PHPUnit_Framework_TestCase
{
$request = new TestRequest('/history/clear');
$request->setHeader('X_REQUESTED_WITH', 'XMLHttpRequest');
Setup::$front->setRequest($request);
Setup::dispatch();
Application::$front->setRequest($request);
Application::dispatch();
$this->assertRegExp(
'{"code":200}',

View File

@ -18,12 +18,12 @@ class IdentityControllerTests extends PHPUnit_Framework_TestCase
public function setUp()
{
TestHarness::setUp();
Setup::$front->returnResponse(true);
Application::$front->returnResponse(true);
$this->_response = new Zend_Controller_Response_Http();
Setup::$front->setResponse($this->_response);
Application::$front->setResponse($this->_response);
// guest user
$users = new Users();
$users = new Users_Model_Users();
$user = $users->createRow();
Zend_Registry::set('user', $user);
}
@ -33,15 +33,15 @@ class IdentityControllerTests extends PHPUnit_Framework_TestCase
*/
public function testIndexNoIdentityAction()
{
Setup::$front->setRequest(new TestRequest('/identity'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/identity'));
Application::dispatch();
}
public function testIdAction()
{
Setup::$front->setRequest(new TestRequest('/identity/whateva'));
Application::$front->setRequest(new TestRequest('/identity/whateva'));
$_SERVER['SCRIPT_URI'] = 'http://localhost/communityid/identity/whateva';
Setup::dispatch();
Application::dispatch();
$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>',

View File

@ -18,14 +18,14 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
public function setUp()
{
TestHarness::setUp();
Setup::$front->returnResponse(true);
Application::$front->returnResponse(true);
$this->_response = new Zend_Controller_Response_Http();
Setup::$front->setResponse($this->_response);
Application::$front->setResponse($this->_response);
$users = new Users();
$users = new Users_Model_Users();
$user = $users->createRow();
$user->id = 23;
$user->role = User::ROLE_ADMIN;
$user->role = Users_Model_User::ROLE_ADMIN;
$user->username = 'testadmin';
Zend_Registry::set('user', $user);
@ -36,10 +36,10 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
*/
public function testIndexGuestUserAction()
{
Zend_Registry::get('user')->role = User::ROLE_GUEST;
Zend_Registry::get('user')->role = Users_Model_User::ROLE_GUEST;
Setup::$front->setRequest(new TestRequest('/messageusers'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers'));
Application::dispatch();
}
/**
@ -47,16 +47,16 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
*/
public function testIndexRegisteredUserAction()
{
Zend_Registry::get('user')->role = User::ROLE_REGISTERED;
Zend_Registry::get('user')->role = Users_Model_User::ROLE_REGISTERED;
Setup::$front->setRequest(new TestRequest('/messageusers'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers'));
Application::dispatch();
}
public function testIndexAction()
{
Setup::$front->setRequest(new TestRequest('/messageusers'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers'));
Application::dispatch();
$this->assertContains('</form>', $this->_response->getBody());
}
@ -71,10 +71,10 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
'bodyHTML' => 'Hello <strong>world</strong>',
);
Setup::$front->setRequest(new TestRequest('/messageusers/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers/send'));
Application::dispatch();
$this->assertContains('Value is empty, but a non-empty value is required', $this->_response->getBody());
$this->assertContains('Value is required and can\'t be empty', $this->_response->getBody());
}
public function testSaveActionWithBadCC()
@ -87,8 +87,8 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
'bodyHTML' => 'Hello <strong>world</strong>',
);
Setup::$front->setRequest(new TestRequest('/messageusers/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers/send'));
Application::dispatch();
$this->assertContains('CC field must be a comma-separated list of valid E-mails', $this->_response->getBody());
}
@ -98,10 +98,10 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
*/
public function testSaveGuestUser()
{
Zend_Registry::get('user')->role = User::ROLE_GUEST;
Zend_Registry::get('user')->role = Users_Model_User::ROLE_GUEST;
Setup::$front->setRequest(new TestRequest('/messageusers/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers/send'));
Application::dispatch();
}
/**
@ -109,10 +109,10 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
*/
public function testSaveRegisteredUser()
{
Zend_Registry::get('user')->role = User::ROLE_REGISTERED;
Zend_Registry::get('user')->role = Users_Model_User::ROLE_REGISTERED;
Setup::$front->setRequest(new TestRequest('/messageusers/send'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/messageusers/send'));
Application::dispatch();
}
public function testSaveSuccessfull()
@ -125,15 +125,15 @@ class MessageusersControllerTests extends PHPUnit_Framework_TestCase
'bodyHTML' => 'Hello <strong>world</strong>',
);
Setup::$front->setRequest(new TestRequest('/messageusers/send'));
Setup::$mockLogger->events = array();
Application::$front->setRequest(new TestRequest('/messageusers/send'));
Application::$mockLogger->events = array();
try {
Setup::dispatch();
Application::dispatch();
} catch (Zend_Controller_Response_Exception $e) {
// I still don't know how to avoid the "headers already sent" problem here...
}
$lastLog = array_pop(Setup::$mockLogger->events);
$lastLog = array_pop(Application::$mockLogger->events);
$this->assertEquals("redirected to ''", $lastLog['message']);
}
}

View File

@ -32,15 +32,15 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
{
TestHarness::setUp();
Setup::$front->returnResponse(true);
Application::$front->returnResponse(true);
$this->_response = new Zend_Controller_Response_Http();
Setup::$front->setResponse($this->_response);
Application::$front->setResponse($this->_response);
$users = new Users();
$users = new Users_Model_Users();
$this->_user = $users->createRow();
$this->_user->test = 1;
$this->_user->username = 'testuser';
$this->_user->role = User::ROLE_REGISTERED;
$this->_user->role = Users_Model_User::ROLE_REGISTERED;
$this->_user->openid = 'http://localhost/communityid/identity/'.$this->_user->username;
$this->_user->accepted_eula = 1;
$this->_user->firstname = 'firstnametest';
@ -56,8 +56,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
*/
public function testIndexAction()
{
Setup::$front->setRequest(new TestRequest('/openid'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid'));
Application::dispatch();
}
public function testProviderAssociateAction()
@ -75,8 +75,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
// needed by Zend_OpenId_Provider
$_SERVER["REQUEST_METHOD"] = 'POST';
Setup::$front->setRequest(new TestRequest('/openid/provider'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/provider'));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -104,8 +104,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/provider?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.identity=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.claimed_id=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.assoc_handle='.self::$assocHandle.'&openid.return_to=http%3A%2F%2Fwww%2Eexample%2Ecom&openid.realm=http%3A%2F%2Fwww%2Eexample%2Ecom'));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/provider?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.identity=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.claimed_id=http%3A%2F%2Flocalhost%2Fcommunityid%2Fidentity%2Ftestuser&openid.assoc_handle='.self::$assocHandle.'&openid.return_to=http%3A%2F%2Fwww%2Eexample%2Ecom&openid.realm=http%3A%2F%2Fwww%2Eexample%2Ecom'));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -130,10 +130,10 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
{
$_SERVER['QUERY_STRING'] = sprintf(self::CHECKID_QUERY, self::$assocHandle);
Setup::$front->setRequest(new TestRequest('/openid/login?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/login?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertContains('<form action="authenticate?'.$_SERVER['QUERY_STRING'].'" method="post">', $this->_response->getBody());
$this->assertContains('<form action="authenticate?'.$_SERVER['QUERY_STRING'].'" method="post" class="formGrid">', $this->_response->getBody());
}
public function testAuthenticateEmptyUsernameAction()
@ -145,10 +145,10 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
'password' => 'whateva',
);
Setup::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertContains('Value is empty, but a non-empty value is required', $this->_response->getBody());
$this->assertContains('Login', $this->_response->getBody());
}
public function testAuthenticateBadUsernameAction()
@ -162,8 +162,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -195,8 +195,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -228,8 +228,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/authenticate?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -252,7 +252,7 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
public function testTrustAction1()
{
$openIdUser = new OpenIdUser();
$openIdUser = new Users_Model_OpenIdUser();
$openIdUser->setLoggedInUser($this->_user->openid);
$_SERVER['QUERY_STRING'] = sprintf(self::CHECKID_QUERY, self::$assocHandle);
@ -262,8 +262,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -286,13 +286,13 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
public function testTrustAction2()
{
$openIdUser = new OpenIdUser();
$openIdUser = new Users_Model_OpenIdUser();
$openIdUser->setLoggedInUser($this->_user->openid);
$_SERVER['QUERY_STRING'] = sprintf(self::CHECKID_QUERY, self::$assocHandle);
Setup::$front->setRequest(new TestRequest('/openid/trust?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/trust?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertContains(
'A site identifying as <a href="http://www.example.com/">http://www.example.com/</a> has asked for confirmation that <a href="'.$this->_user->openid.'">'.$this->_user->openid.'</a> is your identity URL.',
@ -302,7 +302,7 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
public function testProviderProceedAction()
{
$openIdUser = new OpenIdUser();
$openIdUser = new Users_Model_OpenIdUser();
$openIdUser->setLoggedInUser($this->_user->openid);
$_SERVER['QUERY_STRING'] = sprintf(self::CHECKID_QUERY, self::$assocHandle);
@ -316,8 +316,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
'action' => 'proceed',
'allow' => 'Allow',
);
Setup::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -351,7 +351,7 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
$sreg = new Zend_OpenId_Extension_Sreg($sregData);
$storage = new Monkeys_OpenId_Provider_Storage_Database();
$storage->addSite($this->_user->openid, 'http://www.example.com', array('Zend_OpenId_Extension_Sreg' => $sregData));
$openIdUser = new OpenIdUser();
$openIdUser = new Users_Model_OpenIdUser();
$openIdUser->setLoggedInUser($this->_user->openid);
$queryString = self::CHECKID_QUERY . "&openid.ns.sreg=http%%3A%%2F%%2Fopenid.net%%2Fextensions%%2Fsreg%%2F1.1&openid.sreg.required=nickname&openid.sreg.optional=email%%2Cfullname";
@ -366,8 +366,8 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
Zend_OpenId::$exitOnRedirect = false;
Setup::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Setup::dispatch();
Application::$front->setRequest(new TestRequest('/openid/provider?' . $_SERVER['QUERY_STRING']));
Application::dispatch();
$this->assertEquals(
preg_match(
@ -397,7 +397,7 @@ class OpenidControllerTests extends PHPUnit_Framework_TestCase
public function tearDown()
{
$users = new Users();
$users = new Users_Model_Users();
$this->_user->delete();
}
}