code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
function beforeFilter() { $this->TestAuth->ajaxLogin = 'test_element'; $this->TestAuth->userModel = 'AuthUser'; $this->TestAuth->RequestHandler->ajaxLayout = 'ajax2'; }
beforeFilter method @access public @return void
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function add() { if ($this->TestAuth->testStop !== true) { echo 'Added Record'; } }
add method @access public @return void
add
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function redirect($url, $status = null, $exit = true) { $this->testUrl = Router::url($url); return false; }
redirect method @param mixed $url @param mixed $status @param mixed $exit @access public @return void
redirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function startTest() { $this->_server = $_SERVER; $this->_env = $_ENV; $this->_securitySalt = Configure::read('Security.salt'); Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); $this->_acl = Configure::read('Acl'); Configure::write('Acl.database', 'test_suite'); Configure::write('Acl.classname', 'DbAcl'); $this->Controller =& new AuthTestController(); $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); ClassRegistry::addObject('view', new View($this->Controller)); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); Router::reload(); $this->initialized = true; }
startTest method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function endTest() { $_SERVER = $this->_server; $_ENV = $this->_env; Configure::write('Acl', $this->_acl); Configure::write('Security.salt', $this->_securitySalt); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); ClassRegistry::flush(); unset($this->Controller, $this->AuthUser); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testIdentify() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->identify($user)); }
testIdentify method @access public @return void
testIdentify
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testIdentifyWithConditions() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->assertFalse($this->Controller->Auth->identify($user, array('AuthUser.id >' => 2))); $this->Controller->Auth->userScope = array('id >' => 2); $this->assertFalse($this->Controller->Auth->identify($user)); $this->assertTrue($this->Controller->Auth->identify($user, false)); }
testIdentifyWithConditions method @access public @return void
testIdentifyWithConditions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLogin() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $authUser = $this->AuthUser->find(); $this->Controller->data['AuthUser']['username'] = $authUser['AuthUser']['username']; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array('AuthUser' => array( 'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'blah'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 --'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 # something'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->userModel = 'UuidUser'; $this->Controller->Auth->login('47c36f9c-bc00-4d17-9626-4e183ca6822b'); $user = $this->Controller->Auth->user(); $expected = array('UuidUser' => array( 'id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31' )); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); }
testLogin method @access public @return void
testLogin
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginActionNotSettingAuthRedirect() { $_referer = $_SERVER['HTTP_REFERER']; $_SERVER['HTTP_REFERER'] = '/pages/display/about'; $this->Controller->data = array(); $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Session->delete('Auth'); $this->Controller->Auth->loginRedirect = '/users/dashboard'; $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $redirect = $this->Controller->Session->read('Auth.redirect'); $this->assertNull($redirect); }
test that being redirected to the login page, with no post data does not set the session value. Saving the session value in this circumstance can cause the user to be redirected to an already public page. @return void
testLoginActionNotSettingAuthRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeFalse() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = false; $this->Controller->params = Router::parse('auth_test/add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->Session->delete('Auth'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->Controller->params = Router::parse('auth_test/camelCase'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); }
testAuthorizeFalse method @access public @return void
testAuthorizeFalse
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeController() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'controller'; $this->Controller->params = Router::parse('auth_test/add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->params['testControllerAuth'] = 1; $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertFalse($result); $this->Controller->Session->delete('Auth'); }
testAuthorizeController method @access public @return void
testAuthorizeController
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeModel() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = array('model'=>'AuthUser'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); $result = $this->Controller->Auth->isAuthorized(); $this->assertFalse($result); }
testAuthorizeModel method @access public @return void
testAuthorizeModel
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeCrud() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Acl->name = 'DbAclTest'; $this->Controller->Acl->Aro->id = null; $this->Controller->Acl->Aro->create(array('alias' => 'Roles')); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aro->id; $this->Controller->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Admin')); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aro->id; $this->Controller->Acl->Aro->create(array( 'model' => 'AuthUser', 'parent_id' => $parent, 'foreign_key' => 1, 'alias'=> 'mariano' )); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $this->Controller->Acl->Aco->create(array('alias' => 'Root')); $result = $this->Controller->Acl->Aco->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aco->id; $this->Controller->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'AuthTest')); $result = $this->Controller->Acl->Aco->save(); $this->assertTrue($result); $this->Controller->Acl->allow('Roles/Admin', 'Root'); $this->Controller->Acl->allow('Roles/Admin', 'Root/AuthTest'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'crud'; $this->Controller->Auth->actionPath = 'Root/'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->isAuthorized()); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); }
testAuthorizeCrud method @access public @return void
testAuthorizeCrud
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeActions() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Acl =& new AuthTestMockAclComponent(); $this->Controller->Acl->setReturnValue('check', true); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'actions'; $this->Controller->Auth->actionPath = 'Root/'; $this->Controller->Acl->expectAt(0, 'check', array( $user, 'Root/AuthTest/add' )); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->isAuthorized()); }
test authorize = 'actions' setting. @return void
testAuthorizeActions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAllowDenyAll() { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny('add', 'camelcase'); $this->Controller->params['action'] = 'delete'; $this->assertTrue($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'Add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'camelCase'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny(array('add', 'camelcase')); $this->Controller->params['action'] = 'camelCase'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); }
Tests that deny always takes precedence over allow @access public @return void
testAllowDenyAll
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testActionMethod() { $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->actionPath = 'ROOT/'; $result = $this->Controller->Auth->action(); $this->assertEqual($result, 'ROOT/AuthTest/add'); $result = $this->Controller->Auth->action(':controller'); $this->assertEqual($result, 'ROOT/AuthTest'); $result = $this->Controller->Auth->action(':controller'); $this->assertEqual($result, 'ROOT/AuthTest'); $this->Controller->params['plugin'] = 'test_plugin'; $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->initialize($this->Controller); $result = $this->Controller->Auth->action(); $this->assertEqual($result, 'ROOT/TestPlugin/AuthTest/add'); }
test the action() method @return void
testActionMethod
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testDenyWithCamelCaseMethods() { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny('add', 'camelCase'); $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->assertFalse($this->Controller->Auth->startup($this->Controller)); }
test that deny() converts camel case inputs to lowercase. @return void
testDenyWithCamelCaseMethods
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAllowedActionsWithCamelCaseMethods() { $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allow('*'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allowedActions = array('delete', 'camelCase', 'add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); $this->Controller->Auth->allowedActions = array('delete', 'add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s'); $url = '/auth_test/delete'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allow(array('delete', 'add')); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); }
test that allow() and allowedActions work with camelCase method names. @return void
testAllowedActionsWithCamelCaseMethods
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginRedirect() { if (isset($_SERVER['HTTP_REFERER'])) { $backup = $_SERVER['HTTP_REFERER']; } else { $backup = null; } $_SERVER['HTTP_REFERER'] = false; $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate') )); $this->Controller->params = Router::parse('users/login'); $this->Controller->params['url']['url'] = 'users/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->loginRedirect = array( 'controller' => 'pages', 'action' => 'display', 'welcome' ); $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize($this->Controller->Auth->loginRedirect); $this->assertEqual($expected, $this->Controller->Auth->redirect()); $this->Controller->Session->delete('Auth'); //empty referer no session $_SERVER['HTTP_REFERER'] = false; $_ENV['HTTP_REFERER'] = false; putenv('HTTP_REFERER='); $url = '/posts/view/1'; $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate')) ); $this->Controller->testUrl = null; $this->Controller->params = Router::parse($url); array_push($this->Controller->methods, 'view', 'edit', 'index'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = 'controller'; $this->Controller->params['testControllerAuth'] = true; $this->Controller->Auth->loginAction = array( 'controller' => 'AuthTest', 'action' => 'login' ); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEqual($expected, $this->Controller->testUrl); $this->Controller->Session->delete('Auth'); $_SERVER['HTTP_REFERER'] = Router::url('/admin/', true); $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id'=>'1', 'username'=>'nate')) ); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->loginRedirect = false; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/admin'); $this->assertEqual($expected, $this->Controller->Auth->redirect()); //Ticket #4750 //named params $this->Controller->Session->delete('Auth'); $url = '/posts/index/year:2008/month:feb'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/year:2008/month:feb'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); //passed args $this->Controller->Session->delete('Auth'); $url = '/posts/view/1'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/view/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); // QueryString parameters $_back = $_GET; $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', 'refer' => 'menu' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29?print=true&refer=menu'; $this->Controller->params = Dispatcher::parseParams($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', 'refer' => 'menu', 'ext' => 'html' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29?print=true&refer=menu'; $this->Controller->params = Dispatcher::parseParams($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = $_back; //external authed action $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/posts/edit/1'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/posts/edit/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); //external direct login link $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/AuthTest/login'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_SERVER['HTTP_REFERER'] = $backup; $this->Controller->Session->delete('Auth'); }
testLoginRedirect method @access public @return void
testLoginRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testNoRedirectOn404() { $this->Controller->Session->delete('Auth'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->params = Router::parse('auth_test/something_totally_wrong'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'Auth redirected a missing action %s'); }
Ensure that no redirect is performed when a 404 is reached And the user doesn't have a session. @return void
testNoRedirectOn404
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testEmptyUsernameOrPassword() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $authUser = $this->AuthUser->find(); $this->Controller->data['AuthUser']['username'] = ''; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertEqual($user, false); $this->Controller->Session->delete('Auth'); }
testEmptyUsernameOrPassword method @access public @return void
testEmptyUsernameOrPassword
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testInjection() { $this->AuthUser =& new AuthUser(); $this->AuthUser->id = 2; $this->AuthUser->saveField('password', Security::hash(Configure::read('Security.salt') . 'cake')); $this->Controller->data['AuthUser']['username'] = 'nate'; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_array($this->Controller->Auth->user())); $this->Controller->Session->delete($this->Controller->Auth->sessionKey); $this->Controller->data['AuthUser']['username'] = 'nate'; $this->Controller->data['AuthUser']['password'] = 'cake1'; $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); $this->Controller->Session->delete($this->Controller->Auth->sessionKey); $this->Controller->data['AuthUser']['username'] = '> n'; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); unset($this->Controller->data['AuthUser']['password']); $this->Controller->data['AuthUser']['username'] = "1'1"; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); unset($this->Controller->data['AuthUser']['username']); $this->Controller->data['AuthUser']['password'] = "1'1"; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); }
testInjection method @access public @return void
testInjection
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testHashPasswords() { $this->Controller->Auth->userModel = 'AuthUser'; $data['AuthUser']['password'] = 'superSecret'; $data['AuthUser']['username'] = '[email protected]'; $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); $this->assertEqual($return, $expected); $data['Wrong']['password'] = 'superSecret'; $data['Wrong']['username'] = '[email protected]'; $data['AuthUser']['password'] = 'IcantTellYou'; $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); $this->assertEqual($return, $expected); if (PHP5) { $xml = array( 'User' => array( 'username' => '[email protected]', 'password' => 'bruceWayne', ) ); $data =& new Xml($xml); $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $this->assertEqual($return, $expected); } }
test Hashing of passwords @return void
testHashPasswords
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testCustomRoute() { Router::reload(); Router::connect( '/:lang/:controller/:action/*', array('lang' => null), array('lang' => '[a-z]{2,3}') ); $url = '/en/users/login'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->AuthUser =& new AuthUser(); $user = array( 'id' => 1, 'username' => 'felix', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUser->save($user, false); $this->Controller->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('lang' => 'en', 'controller' => 'users', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); $this->Controller->Session->delete('Auth'); Router::reload(); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); }
testCustomRoute method @access public @return void
testCustomRoute
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testCustomField() { Router::reload(); $this->AuthUserCustomField =& new AuthUserCustomField(); $user = array( 'id' => 1, 'email' => '[email protected]', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUserCustomField->save($user, false); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUserCustomField'] = array('email' => '[email protected]', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUserCustomField'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); }
testCustomField method @access public @return void
testCustomField
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAdminRoute() { $prefixes = Configure::read('Routing.prefixes'); Configure::write('Routing.prefixes', array('admin')); Router::reload(); $url = '/admin/auth_test/add'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'add', 'plugin' => null, 'controller' => 'auth_test', 'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']) ), array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), ) )); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array( 'admin' => true, 'controller' => 'auth_test', 'action' => 'login' ); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertEqual($this->Controller->testUrl, '/admin/auth_test/login'); Configure::write('Routing.prefixes', $prefixes); }
testAdminRoute method @access public @return void
testAdminRoute
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testPluginModel() { // Adding plugins Cache::delete('object_map', '_cake_core_'); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS) ), true); App::objects('plugin', null, false); $PluginModel =& ClassRegistry::init('TestPlugin.TestPluginAuthUser'); $user['id'] = 1; $user['username'] = 'gwoo'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $PluginModel->save($user, false); $authUser = $PluginModel->find(); $this->Controller->data['TestPluginAuthUser']['username'] = $authUser['TestPluginAuthUser']['username']; $this->Controller->data['TestPluginAuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'TestPlugin.TestPluginAuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array('TestPluginAuthUser' => array( 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $sessionKey = $this->Controller->Auth->sessionKey; $this->assertEqual('Auth.TestPluginAuthUser', $sessionKey); $this->Controller->Auth->loginAction = null; $this->Controller->Auth->__setDefaults(); $loginAction = $this->Controller->Auth->loginAction; $expected = array( 'controller' => 'test_plugin_auth_users', 'action' => 'login', 'plugin' => 'test_plugin' ); $this->assertEqual($loginAction, $expected); // Reverting changes Cache::delete('object_map', '_cake_core_'); App::build(); App::objects('plugin', null, false); }
testPluginModel method @access public @return void
testPluginModel
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAjaxLogin() { App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS))); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; if (!class_exists('dispatcher')) { require CAKE . 'dispatcher.php'; } ob_start(); $Dispatcher =& new Dispatcher(); $Dispatcher->dispatch('/ajax_auth/add', array('return' => 1)); $result = ob_get_clean(); $this->assertEqual("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result)); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testAjaxLogin method @access public @return void
testAjaxLogin
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginActionRedirect() { $admin = Configure::read('Routing.admin'); Configure::write('Routing.admin', 'admin'); Router::reload(); $url = '/admin/auth_test/login'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', 'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']), ), array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), ) )); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertNull($this->Controller->testUrl); Configure::write('Routing.admin', $admin); }
testLoginActionRedirect method @access public @return void
testLoginActionRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testShutDown() { $this->Controller->Session->write('Auth.redirect', 'foo'); $this->Controller->Auth->_loggedIn = true; $this->Controller->Auth->shutdown($this->Controller); $this->assertFalse($this->Controller->Session->read('Auth.redirect')); }
Tests that shutdown destroys the redirect session var @access public @return void
testShutDown
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testInitializeAndRoutingPrefixes() { $restore = Configure::read('Routing'); Configure::write('Routing.prefixes', array('admin', 'super_user')); Router::reload(); $this->Controller->Auth->initialize($this->Controller); $this->assertTrue(isset($this->Controller->Auth->actionMap['delete'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['view'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['add'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['admin_view'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['super_user_delete'])); Configure::write('Routing', $restore); }
test the initialize callback and its interactions with Router::prefixes() @return void
testInitializeAndRoutingPrefixes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testComponentSettings() { $this->Controller =& new AuthTestController(); $this->Controller->components = array( 'Auth' => array( 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'userModel' => 'AuthUserCustomField', 'sessionKey' => 'AltAuth.AuthUserCustomField' ), 'Session' ); $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); Router::reload(); $this->AuthUserCustomField =& new AuthUserCustomField(); $user = array( 'id' => 1, 'email' => '[email protected]', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUserCustomField->save($user, false); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUserCustomField'] = array('email' => '[email protected]', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); $expected = array( 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), 'userModel' => 'AuthUserCustomField', 'sessionKey' => 'AltAuth.AuthUserCustomField' ); $this->assertEqual($expected['fields'], $this->Controller->Auth->fields); $this->assertEqual($expected['loginAction'], $this->Controller->Auth->loginAction); $this->assertEqual($expected['logoutRedirect'], $this->Controller->Auth->logoutRedirect); $this->assertEqual($expected['userModel'], $this->Controller->Auth->userModel); $this->assertEqual($expected['sessionKey'], $this->Controller->Auth->sessionKey); }
test $settings in Controller::$components @access public @return void
testComponentSettings
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLogout() { $this->Controller->Session->write('Auth.User.id', '1'); $this->Controller->Session->write('Auth.redirect', '/users/login'); $this->Controller->Auth->logoutRedirect = '/'; $result = $this->Controller->Auth->logout(); $this->assertEqual($result, '/'); $this->assertNull($this->Controller->Session->read('Auth.AuthUser')); $this->assertNull($this->Controller->Session->read('Auth.redirect')); }
test that logout deletes the session variables. and returns the correct url @return void
testLogout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function beforeFilter() { $this->Cookie->name = 'CakeTestCookie'; $this->Cookie->time = 10; $this->Cookie->path = '/'; $this->Cookie->domain = ''; $this->Cookie->secure = false; $this->Cookie->key = 'somerandomhaskey'; }
beforeFilter method @access public @return void
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testInitialize() { $settings = array( 'time' => '5 days', 'path' => '/' ); $this->Controller->Cookie->initialize($this->Controller, $settings); $this->assertEqual($this->Controller->Cookie->time, $settings['time']); $this->assertEqual($this->Controller->Cookie->path, $settings['path']); }
test that initialize sets settings from components array @return void
testInitialize
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testNoErrorOnNonArrayData() { $this->Controller->Cookie->destroy(); $_COOKIE['CakeTestCookie'] = 'kaboom'; $this->assertNull($this->Controller->Cookie->read('value')); }
test that no error is issued for non array data. @return void
testNoErrorOnNonArrayData
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testDeleteRemovesChildren() { $_COOKIE['CakeTestCookie'] = array( 'User' => array('email' => '[email protected]', 'name' => 'mark'), 'other' => 'value' ); $this->Controller->Cookie->startup(); $this->assertEqual('mark', $this->Controller->Cookie->read('User.name')); $this->Controller->Cookie->delete('User'); $this->assertFalse($this->Controller->Cookie->read('User.email')); $this->Controller->Cookie->destroy(); }
test that deleting a top level keys kills the child elements too. @return void
testDeleteRemovesChildren
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testDeleteChildrenNotExist() { $this->assertNull($this->Controller->Cookie->delete('NotFound')); $this->assertNull($this->Controller->Cookie->delete('Not.Found')); }
Test deleting recursively with keys that don't exist. @return void
testDeleteChildrenNotExist
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testForwardsCompatibility() { if ($this->skipIf(!function_exists('json_decode'), 'no json_decode, skipping.')) { return; } $_COOKIE['CakeTestCookie'] = array( 'JSON' => '{"name":"value"}', 'Empty' => '', 'String' => '{"somewhat:"broken"}' ); $this->Controller->Cookie->startup($this->Controller); $this->assertEqual(array('name' => 'value'), $this->Controller->Cookie->read('JSON')); $this->assertEqual('value', $this->Controller->Cookie->read('JSON.name')); $this->assertEqual('', $this->Controller->Cookie->read('Empty')); $this->assertEqual('{"somewhat:"broken"}', $this->Controller->Cookie->read('String')); }
Test that 1.3 can read 2.0 format codes if json_encode exists. @return void
testForwardsCompatibility
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function __encrypt($value) { if (is_array($value)) { $value = $this->__implode($value); } return "Q2FrZQ==." . base64_encode(Security::cipher($value, $this->Controller->Cookie->key)); }
encrypt method @param mixed $value @return string @access private
__encrypt
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function __implode($array) { $string = ''; foreach ($array as $key => $value) { $string .= ',' . $key . '|' . $value; } return substr($string, 1); }
implode method @param array $value @return string @access private
__implode
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function smtpSend($data, $code = '250') { return parent::_smtpSend($data, $code); }
smtpSend method override for testing @access public @return mixed
smtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setConnectionSocket(&$socket) { $this->__smtpConnection = $socket; }
Convenience setter method for testing. @access public @return void
setConnectionSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function _getSocket($config) { if (empty($this->__smtpConnection)) { parent::_getSocket($config); } }
Allows mocks to be used with tests. @param array $config @return void
_getSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getConnectionSocket() { return $this->__smtpConnection; }
Convenience getter method for testing. @access public @return mixed
getConnectionSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setHeaders($headers) { $this->__header += $headers; }
Convenience setter for testing. @access public @return void
setHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getHeaders() { return $this->__header; }
Convenience getter for testing. @access public @return array
getHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getBoundary() { return $this->__boundary; }
Convenience getter for testing. @access public @return string
getBoundary
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getMessage() { return $this->__message; }
Convenience getter for testing. @access public @return string
getMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function _getMessage() { return $this->__message; }
Convenience getter for testing. @access protected @return string
_getMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function strip($content, $message = false) { return parent::_strip($content, $message); }
Convenience method for testing. @access public @return string
strip
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setUp() { $this->_appEncoding = Configure::read('App.encoding'); Configure::write('App.encoding', 'UTF-8'); $this->Controller =& new EmailTestController(); restore_error_handler(); @$this->Controller->Component->init($this->Controller); set_error_handler('simpleTestErrorHandler'); $this->Controller->EmailTest->initialize($this->Controller, array()); ClassRegistry::addObject('view', new View($this->Controller)); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function tearDown() { Configure::write('App.encoding', $this->_appEncoding); App::build(); $this->Controller->Session->delete('Message'); restore_error_handler(); ClassRegistry::flush(); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function __osFix($string) { return str_replace(array("\r\n", "\r"), "\n", $string); }
osFix method @param string $string @access private @return string
__osFix
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpConfig() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions = array(); $this->Controller->EmailTest->send('anything'); $config = array( 'host' => 'localhost', 'port' => 25, 'protocol' => 'smtp', 'timeout' => 30 ); $this->assertEqual($config, $this->Controller->EmailTest->smtpOptions); $this->Controller->EmailTest->smtpOptions = array('port' => 80); $this->Controller->EmailTest->send('anything'); $config['port'] = 80; $this->assertEqual($config, $this->Controller->EmailTest->smtpOptions); }
testSmtpConfig method @access public @return void
testSmtpConfig
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testBadSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertFalse($this->Controller->EmailTest->send('Should not work')); }
testBadSmtpSend method @access public @return void
testBadSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $expect = <<<TEMPDOC <pre>Host: localhost Port: 25 Timeout: 30 To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: To: postmaster@localhost From: [email protected] Reply-To: [email protected] Subject: Cake SMTP test X-Mailer: CakePHP Email Component Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> TEMPDOC; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSmtpSend method @access public @return void
testSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpEhlo() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $connection =& new CakeSocket(array('protocol'=>'smtp', 'host' => 'localhost', 'port' => 25)); $this->Controller->EmailTest->setConnectionSocket($connection); $this->Controller->EmailTest->smtpOptions['timeout'] = 10; $this->assertTrue($connection->connect()); $this->assertTrue($this->Controller->EmailTest->smtpSend(null, '220') !== false); $this->skipIf($this->Controller->EmailTest->smtpSend('EHLO locahost', '250') === false, '%s do not support EHLO.'); $connection->disconnect(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $expect = <<<TEMPDOC <pre>Host: localhost Port: 25 Timeout: 30 To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: To: postmaster@localhost From: [email protected] Reply-To: [email protected] Subject: Cake SMTP test X-Mailer: CakePHP Email Component Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> TEMPDOC; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSmtpEhlo method @access public @return void
testSmtpEhlo
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendMultipleTo() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP multiple To test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $this->Controller->EmailTest->delivery = 'smtp'; $socket = new MockEmailSocket(); $socket->setReturnValue('connect', true); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertPattern('/EHLO localhost\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/MAIL FROM: <noreply@example\.com>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/RCPT TO: <postmaster@localhost>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/RCPT TO: <root@localhost>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern( '/To: postmaster@localhost, root@localhost[\n\r]/', $this->Controller->EmailTest->smtpSend ); }
testSmtpSendMultipleTo method @access public @return void
testSmtpSendMultipleTo
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendHostWithPort() { $bkp = env('HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'localhost:8080'; $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('root@localhost'); $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP host test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->sendAs = 'text'; $this->Controller->EmailTest->_debug = true; $socket = new MockEmailSocket(); $socket->setReturnValue('connect', true); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertPattern('/EHLO localhost\n/', $this->Controller->EmailTest->smtpSend); $_SERVER['HTTP_HOST'] = $bkp; }
test sending smtp from a host using a port. @return void
testSmtpSendHostWithPort
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testAuthenticatedSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->smtpOptions['username'] = 'test'; $this->Controller->EmailTest->smtpOptions['password'] = 'testing'; $this->Controller->EmailTest->delivery = 'smtp'; $result = $this->Controller->EmailTest->send('This is the body of the message'); $code = substr($this->Controller->EmailTest->smtpError, 0, 3); $this->skipIf(!$code, '%s Authentication not enabled on server'); $this->assertFalse($result); $this->assertEqual($code, '535'); }
testAuthenticatedSmtpSend method @access public @return void
testAuthenticatedSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendFormats() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $date = date(DATE_RFC2822); $message = <<<MSGBLOC <pre>To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: From: [email protected] Reply-To: [email protected] Date: $date X-Mailer: CakePHP Email Component Content-Type: {CONTENTTYPE} Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> MSGBLOC; $this->Controller->EmailTest->sendAs = 'text'; $expect = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'html'; $expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); // TODO: better test for format of message sent? $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-' . $boundary . '"', $message); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSendFormats method @access public @return void
testSendFormats
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testTemplates() { ClassRegistry::flush(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $date = date(DATE_RFC2822); $header = <<<HEADBLOC To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: From: [email protected] Reply-To: [email protected] Date: $date X-Mailer: CakePHP Email Component Content-Type: {CONTENTTYPE} Content-Transfer-Encoding: 7bitParameters: Message: HEADBLOC; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'default'; $text = <<<TEXTBLOC This is the body of the message This email was sent using the CakePHP Framework, http://cakephp.org. TEXTBLOC; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>Email Test</title> </head> <body> <p> This is the body of the message</p><p> </p> <p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'text'; $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'html'; $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-' . $boundary . '"', $header); $expect .= '--alt-' . $boundary . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n"; $expect .= '--alt-' . $boundary . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n"; $expect = '<pre>' . $expect . "--alt-$boundary--" . "\n\n" . '</pre>'; $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>Email Test</title> </head> <body> <p> This is the body of the message</p><p> </p> <p>This email was sent using the CakePHP Framework</p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html; $expect = '<pre>' . $expect . '</pre>'; $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $result = ClassRegistry::getObject('view'); $this->assertFalse($result); }
testTemplates method @access public @return void
testTemplates
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testTemplateNestedElements() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'nested_element'; $this->Controller->EmailTest->sendAs = 'html'; $this->Controller->helpers = array('Html'); $this->Controller->EmailTest->send(); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Test/', $result); $this->assertPattern('/http\:\/\/example\.com/', $result); }
test that elements used in email templates get helpers. @return void
testTemplateNestedElements
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendSocket() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->smtpOptions['timeout'] = 10; $socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions)); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->getConnectionSocket()); $response = $this->Controller->EmailTest->smtpSend('HELO', '250'); $this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError); $this->Controller->EmailTest->reset(); $response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250'); $this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError); }
testSmtpSendSocket method @access public @return void
testSmtpSendSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendDebug() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->cc = '[email protected]'; $this->Controller->EmailTest->bcc = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/Cc: [email protected]\n/', $result); $this->assertPattern('/Bcc: [email protected]\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/This is the body of the message/', $result); }
testSendDebug method @access public @return void
testSendDebug
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendDebugWithNoSessions() { $session =& $this->Controller->Session; unset($this->Controller->Session); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $result = $this->Controller->EmailTest->send('This is the body of the message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/This is the body of the message/', $result); $this->Controller->Session = $session; }
test send with delivery = debug and not using sessions. @return void
testSendDebugWithNoSessions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageRetrievalWithoutTemplate() { App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $text = $html = 'This is the body of the message'; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertNull($this->Controller->EmailTest->htmlMessage); $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); }
testMessageRetrievalWithoutTemplate method @access public @return void
testMessageRetrievalWithoutTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageRetrievalWithTemplate() { App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $this->Controller->set('value', 22091985); $this->Controller->set('title_for_layout', 'EmailTest'); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'custom'; $this->Controller->EmailTest->delivery = 'debug'; $text = <<<TEXTBLOC Here is your value: 22091985 This email was sent using the CakePHP Framework, http://cakephp.org. TEXTBLOC; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>EmailTest</title> </head> <body> <p>Here is your value: <b>22091985</b></p> <p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertNull($this->Controller->EmailTest->htmlMessage); $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); }
testMessageRetrievalWithTemplate method @access public @return void
testMessageRetrievalWithTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendContentArray() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $content = array('First line', 'Second line', 'Third line'); $this->assertTrue($this->Controller->EmailTest->send($content)); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/First line\n/', $result); $this->assertPattern('/Second line\n/', $result); $this->assertPattern('/Third line\n/', $result); }
testContentArray method @access public @return void
testSendContentArray
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testDateProperty() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('test message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Date: Today!\n/', $result); }
test setting a custom date. @return void
testDateProperty
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testContentStripping() { $content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit"; $content .= "\n\n<p>My own html content</p>"; $result = $this->Controller->EmailTest->strip($content, true); $expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>"; $this->assertEqual($result, $expected); $content = '<p>Some HTML content with an <a href="mailto:[email protected]">email link</a>'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); $content = '<p>Some HTML content with an '; $content .= '<a href="mailto:[email protected],[email protected]">email link</a>'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); $content = 'This is a test email to: you and whomever you forward it to'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); }
testContentStripping method @access public @return void
testContentStripping
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendWithAttachments() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->attachments = array( __FILE__, 'some-name.php' => __FILE__ ); $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename="email.test.php"') . '/', $msg); $this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename="some-name.php"') . '/', $msg); }
undocumented function @return void @access public
testSendWithAttachments
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendAsIsNotIgnoredIfAttachmentsPresent() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->attachments = array(__FILE__); $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/text\/plain/', $msg); $this->assertPattern('/text\/html/', $msg); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/text\/plain/', $msg); $this->assertNoPattern('/text\/html/', $msg); $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/text\/plain/', $msg); $this->assertNoPattern('/text\/html/', $msg); $this->assertPattern('/multipart\/alternative/', $msg); }
testSendAsIsNotIgnoredIfAttachmentsPresent method @return void @access public
testSendAsIsNotIgnoredIfAttachmentsPresent
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testNoDoubleNewlinesInHeaders() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/\n\nContent-Transfer-Encoding/', $msg); $this->assertPattern('/\nContent-Transfer-Encoding/', $msg); }
testNoDoubleNewlinesInHeaders function @return void @access public
testNoDoubleNewlinesInHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testReset() { $this->Controller->EmailTest->template = 'test_template'; $this->Controller->EmailTest->to = '[email protected]'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->return = '[email protected]'; $this->Controller->EmailTest->cc = array('[email protected]', '[email protected]'); $this->Controller->EmailTest->bcc = array('[email protected]', '[email protected]'); $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->subject = 'Test subject'; $this->Controller->EmailTest->additionalParams = 'X-additional-header'; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; $this->Controller->EmailTest->smtpOptions['timeout'] = 0.5; $this->Controller->EmailTest->attachments = array('attachment1', 'attachment2'); $this->Controller->EmailTest->textMessage = 'This is the body of the message'; $this->Controller->EmailTest->htmlMessage = 'This is the body of the message'; $this->Controller->EmailTest->messageId = false; $this->assertFalse($this->Controller->EmailTest->send('Should not work')); $this->Controller->EmailTest->reset(); $this->assertNull($this->Controller->EmailTest->template); $this->assertIdentical($this->Controller->EmailTest->to, array()); $this->assertNull($this->Controller->EmailTest->from); $this->assertNull($this->Controller->EmailTest->replyTo); $this->assertNull($this->Controller->EmailTest->return); $this->assertIdentical($this->Controller->EmailTest->cc, array()); $this->assertIdentical($this->Controller->EmailTest->bcc, array()); $this->assertNull($this->Controller->EmailTest->date); $this->assertNull($this->Controller->EmailTest->subject); $this->assertNull($this->Controller->EmailTest->additionalParams); $this->assertIdentical($this->Controller->EmailTest->getHeaders(), array()); $this->assertNull($this->Controller->EmailTest->getBoundary()); $this->assertIdentical($this->Controller->EmailTest->getMessage(), array()); $this->assertNull($this->Controller->EmailTest->smtpError); $this->assertIdentical($this->Controller->EmailTest->attachments, array()); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertTrue($this->Controller->EmailTest->messageId); $this->assertEqual('mail', $this->Controller->EmailTest->delivery); }
testReset method @access public @return void
testReset
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageId() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Message-ID: \<[a-f0-9]{32}@' . env('HTTP_HOST') . '\>\n/', $result); $this->Controller->EmailTest->messageId = '<22091985.998877@localhost>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Message-ID: <22091985.998877@localhost>\n/', $result); $this->Controller->EmailTest->messageId = false; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/Message-ID:/', $result); }
testMessageId method @access public @return void
testMessageId
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendMessage() { $this->Controller->EmailTest->delivery = 'getMessage'; $this->Controller->EmailTest->lineLength = 70; $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; $this->Controller->EmailTest->sendAs = 'text'; $result = $this->Controller->EmailTest->send($text); $expected = array( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do', 'eiusmod tempor incididunt ut labore et dolore magna aliqua.', '', '' ); $this->assertEqual($expected, $result); $text = 'Lorem ipsum dolor sit amet, <b>consectetur</b> adipisicing elit, sed do <span>eiusmod tempor</span> incididunt ut labore et dolore magna aliqua.'; $this->Controller->EmailTest->sendAs = 'html'; $result = $this->Controller->EmailTest->send($text); $expected = array( $text, '', '' ); $this->assertEqual($expected, $result); }
testSendMessage method @access public @return void
testSendMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testFormatAddressAliases() { $result = $this->Controller->EmailTest->formatAddress('[email protected]'); $this->assertEqual($result, '[email protected]'); $result = $this->Controller->EmailTest->formatAddress('alias <[email protected]>'); $this->assertEqual($result, 'alias <[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('alias<[email protected]>'); $this->assertEqual($result, 'alias <[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('[email protected]'); $this->assertEqual($result, '[email protected]'); $result = $this->Controller->EmailTest->formatAddress('<[email protected]>'); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('[email protected]', true); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('<[email protected]>', true); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('alias name <[email protected]>', true); $this->assertEqual($result, '<[email protected]>'); }
Test that _formatName doesn't jack up email addresses with alias parts. @return void
testFormatAddressAliases
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function __construct($params = array()) { foreach ($params as $key => $val) { $this->{$key} = $val; } parent::__construct(); }
construct method @param array $params @access private @return void
__construct
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function destination() { $this->viewPath = 'posts'; $this->render('index'); }
test method for ajax redirection @return void
destination
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function param_method($one = null, $two = null) { echo "one: $one two: $two"; $this->autoRender = false; }
test method for ajax redirection + parameter parsing @return void
param_method
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function ajax2_layout() { if ($this->autoLayout) { $this->layout = 'ajax2'; } $this->destination(); }
test method for testing layout rendering when isAjax() @return void
ajax2_layout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function __construct($params = array()) { foreach ($params as $key => $val) { $this->{$key} = $val; } parent::__construct(); }
construct method @param array $params @access private @return void
__construct
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function beforeFilter() { $this->RequestHandler->enabled = false; }
beforeFilter method @return void @access public
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function _init() { $this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler'))); $this->Controller->constructClasses(); $this->RequestHandler =& $this->Controller->RequestHandler; }
init method @access protected @return void
_init
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function endTest() { unset($this->RequestHandler); unset($this->Controller); if (!headers_sent()) { header('Content-type: text/html'); //reset content type. } App::build(); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testInitializeCallback() { $this->assertNull($this->RequestHandler->ext); $this->_init(); $this->Controller->params['url']['ext'] = 'rss'; $this->RequestHandler->initialize($this->Controller); $this->assertEqual($this->RequestHandler->ext, 'rss'); $settings = array( 'ajaxLayout' => 'test_ajax' ); $this->RequestHandler->initialize($this->Controller, $settings); $this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax'); }
testInitializeCallback method @access public @return void
testInitializeCallback
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testDisabling() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->_init(); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); $this->Controller->Component->startup($this->Controller); $this->assertEqual($this->Controller->params, array('isAjax' => true)); $this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler'))); $this->Controller->constructClasses(); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); $this->Controller->Component->startup($this->Controller); $this->assertEqual($this->Controller->params, array()); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testDisabling method @access public @return void
testDisabling
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testAutoResponseType() { $this->Controller->ext = '.thtml'; $this->Controller->params['url']['ext'] = 'rss'; $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertEqual($this->Controller->ext, '.ctp'); }
testAutoResponseType method @access public @return void
testAutoResponseType
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testAutoAjaxLayout() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->RequestHandler->startup($this->Controller); $this->assertTrue($this->Controller->layout, $this->RequestHandler->ajaxLayout); $this->_init(); $this->Controller->params['url']['ext'] = 'js'; $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertNotEqual($this->Controller->layout, 'ajax'); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testAutoAjaxLayout method @access public @return void
testAutoAjaxLayout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testStartupCallback() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml'; $this->RequestHandler->startup($this->Controller); $this->assertTrue(is_array($this->Controller->data)); $this->assertFalse(is_object($this->Controller->data)); }
testStartupCallback method @access public @return void
testStartupCallback
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testNonAjaxRedirect() { $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, '/')); }
testNonAjaxRedirect method @access public @return void
testNonAjaxRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRenderAs() { $this->assertFalse(in_array('Xml', $this->Controller->helpers)); $this->RequestHandler->renderAs($this->Controller, 'xml'); $this->assertTrue(in_array('Xml', $this->Controller->helpers)); $this->Controller->viewPath = 'request_handler_test\\xml'; $this->RequestHandler->renderAs($this->Controller, 'js'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js'); }
testRenderAs method @access public @return void
testRenderAs
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRespondAs() { $RequestHandler = new NoStopRequestHandler(); $RequestHandler->expectAt(0, '_header', array('Content-Type: application/json')); $RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml')); $result = $RequestHandler->respondAs('json'); $this->assertTrue($result); $result = $RequestHandler->respondAs('text/xml'); $this->assertTrue($result); }
test that respondAs works as expected. @return void
testRespondAs
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRespondAsWithAttachment() { $RequestHandler = new NoStopRequestHandler(); $RequestHandler->expectAt(0, '_header', array('Content-Disposition: attachment; filename="myfile.xml"')); $RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml')); $result = $RequestHandler->respondAs('xml', array('attachment' => 'myfile.xml')); $this->assertTrue($result); }
test that attachment headers work with respondAs @return void
testRespondAsWithAttachment
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRenderAsCalledTwice() { $this->RequestHandler->renderAs($this->Controller, 'xml'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'xml'); $this->assertEqual($this->Controller->layoutPath, 'xml'); $this->assertTrue(in_array('Xml', $this->Controller->helpers)); $this->RequestHandler->renderAs($this->Controller, 'js'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js'); $this->assertEqual($this->Controller->layoutPath, 'js'); $this->assertTrue(in_array('Js', $this->Controller->helpers)); }
test that calling renderAs() more than once continues to work. @link #6466 @return void
testRenderAsCalledTwice
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRequestClientTypes() { $this->assertFalse($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash'; $this->assertTrue($this->RequestHandler->isFlash()); unset($_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_REQUESTED_WITH']); $this->assertFalse($this->RequestHandler->isAjax()); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $_SERVER['HTTP_X_PROTOTYPE_VERSION'] = '1.5'; $this->assertTrue($this->RequestHandler->isAjax()); $this->assertEqual($this->RequestHandler->getAjaxVersion(), '1.5'); unset($_SERVER['HTTP_X_REQUESTED_WITH'], $_SERVER['HTTP_X_PROTOTYPE_VERSION']); $this->assertFalse($this->RequestHandler->isAjax()); $this->assertFalse($this->RequestHandler->getAjaxVersion()); }
testRequestClientTypes method @access public @return void
testRequestClientTypes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testFlashDetection() { $_agent = env('HTTP_USER_AGENT'); $_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 9'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 10'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Shock Flash'; $this->assertFalse($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = $_agent; }
Tests the detection of various Flash versions @access public @return void
testFlashDetection
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRequestContentTypes() { $_SERVER['REQUEST_METHOD'] = 'GET'; $this->assertNull($this->RequestHandler->requestedWith()); $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['CONTENT_TYPE'] = 'application/json'; $this->assertEqual($this->RequestHandler->requestedWith(), 'json'); $result = $this->RequestHandler->requestedWith(array('json', 'xml')); $this->assertEqual($result, 'json'); $result =$this->RequestHandler->requestedWith(array('rss', 'atom')); $this->assertFalse($result); $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isXml()); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertFalse($this->RequestHandler->isRSS()); $_SERVER['HTTP_ACCEPT'] = 'application/atom+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isAtom()); $this->assertFalse($this->RequestHandler->isRSS()); $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertTrue($this->RequestHandler->isRSS()); $this->assertFalse($this->RequestHandler->isWap()); $_SERVER['HTTP_ACCEPT'] = 'text/vnd.wap.wml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isWap()); $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml ;q=0.9 , text/xml, application/xml,application/xhtml+xml'; $this->_init(); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertTrue($this->RequestHandler->isRSS()); }
testRequestContentTypes method @access public @return void
testRequestContentTypes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT