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 removeNs($name) { return $this->Xml->removeGlobalNamespace($name); }
Removes a namespace added in addNs() @param string $name The namespace name or URI @deprecated @see Xml::removeNs() @access public
removeNs
php
Datawalke/Coordino
cake/libs/view/helpers/xml.php
https://github.com/Datawalke/Coordino/blob/master/cake/libs/view/helpers/xml.php
MIT
function elem($name, $attrib = array(), $content = null, $endTag = true) { $namespace = null; if (isset($attrib['namespace'])) { $namespace = $attrib['namespace']; unset($attrib['namespace']); } $cdata = false; if (is_array($content) && isset($content['cdata'])) { $cdata = true; unset($content['cdata']); } if (is_array($content) && array_key_exists('value', $content)) { $content = $content['value']; } $children = array(); if (is_array($content)) { $children = $content; $content = null; } $elem =& $this->Xml->createElement($name, $content, $attrib, $namespace); foreach ($children as $child) { $elem->createElement($child); } $out = $elem->toString(array('cdata' => $cdata, 'leaveOpen' => !$endTag)); if (!$endTag) { $this->XmlElement =& $elem; } return $out; }
Generates an XML element @param string $name The name of the XML element @param array $attrib The attributes of the XML element @param mixed $content XML element content @param boolean $endTag Whether the end tag of the element should be printed @return string XML @access public @link http://book.cakephp.org/view/1475/elem
elem
php
Datawalke/Coordino
cake/libs/view/helpers/xml.php
https://github.com/Datawalke/Coordino/blob/master/cake/libs/view/helpers/xml.php
MIT
function closeElem() { $elem = (empty($this->XmlElement)) ? $this->Xml : $this->XmlElement; $name = $elem->name(); if ($parent =& $elem->parent()) { $this->XmlElement =& $parent; } return '</' . $name . '>'; }
Create closing tag for current element @return string @access public
closeElem
php
Datawalke/Coordino
cake/libs/view/helpers/xml.php
https://github.com/Datawalke/Coordino/blob/master/cake/libs/view/helpers/xml.php
MIT
function serialize($data, $options = array()) { $options += array('attributes' => false, 'format' => 'attributes'); $data =& new Xml($data, $options); return $data->toString($options + array('header' => false)); }
Serializes a model resultset into XML @param mixed $data The content to be converted to XML @param array $options The data formatting options. For a list of valid options, see Xml::__construct(). @return string A copy of $data in XML format @see Xml::__construct() @access public @link http://book.cakephp.org/view/1474/serialize
serialize
php
Datawalke/Coordino
cake/libs/view/helpers/xml.php
https://github.com/Datawalke/Coordino/blob/master/cake/libs/view/helpers/xml.php
MIT
function setUp() { App::build(array( 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS) )); $this->_language = Configure::read('Config.language'); }
setUp method @return void @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function tearDown() { App::build(); Configure::write('Config.language', $this->_language); }
tearDown method @return void @access public
tearDown
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testArrayDiffKey() { $one = array('one' => 1, 'two' => 2, 'three' => 3); $two = array('one' => 'one', 'two' => 'two'); $result = array_diff_key($one, $two); $expected = array('three' => 3); $this->assertEqual($result, $expected); $one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3); $two = array('two' => 'two'); $result = array_diff_key($one, $two); $expected = array('one' => array('value', 'value-two'), 'three' => 3); $this->assertEqual($result, $expected); $one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0); $two = array('two' => 'two'); $result = array_diff_key($one, $two); $expected = array('one' => null, 'three' => '', 'four' => 0); $this->assertEqual($result, $expected); $one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); $two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); $result = array_diff_key($one, $two); $this->assertEqual($result, array()); }
test the array_diff_key compatibility function. @return void @access public
testArrayDiffKey
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testEnv() { $this->skipIf(!function_exists('ini_get') || ini_get('safe_mode') === '1', '%s safe mode is on'); $__SERVER = $_SERVER; $__ENV = $_ENV; $_SERVER['HTTP_HOST'] = 'localhost'; $this->assertEqual(env('HTTP_BASE'), '.localhost'); $_SERVER['HTTP_HOST'] = 'com.ar'; $this->assertEqual(env('HTTP_BASE'), '.com.ar'); $_SERVER['HTTP_HOST'] = 'example.ar'; $this->assertEqual(env('HTTP_BASE'), '.example.ar'); $_SERVER['HTTP_HOST'] = 'example.com'; $this->assertEqual(env('HTTP_BASE'), '.example.com'); $_SERVER['HTTP_HOST'] = 'www.example.com'; $this->assertEqual(env('HTTP_BASE'), '.example.com'); $_SERVER['HTTP_HOST'] = 'subdomain.example.com'; $this->assertEqual(env('HTTP_BASE'), '.example.com'); $_SERVER['HTTP_HOST'] = 'example.com.ar'; $this->assertEqual(env('HTTP_BASE'), '.example.com.ar'); $_SERVER['HTTP_HOST'] = 'www.example.com.ar'; $this->assertEqual(env('HTTP_BASE'), '.example.com.ar'); $_SERVER['HTTP_HOST'] = 'subdomain.example.com.ar'; $this->assertEqual(env('HTTP_BASE'), '.example.com.ar'); $_SERVER['HTTP_HOST'] = 'double.subdomain.example.com'; $this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com'); $_SERVER['HTTP_HOST'] = 'double.subdomain.example.com.ar'; $this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com.ar'); $_SERVER = $_ENV = array(); $_SERVER['SCRIPT_NAME'] = '/a/test/test.php'; $this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php'); $_SERVER = $_ENV = array(); $_ENV['CGI_MODE'] = 'BINARY'; $_ENV['SCRIPT_URL'] = '/a/test/test.php'; $this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php'); $_SERVER = $_ENV = array(); $this->assertFalse(env('HTTPS')); $_SERVER['HTTPS'] = 'on'; $this->assertTrue(env('HTTPS')); $_SERVER['HTTPS'] = '1'; $this->assertTrue(env('HTTPS')); $_SERVER['HTTPS'] = 'I am not empty'; $this->assertTrue(env('HTTPS')); $_SERVER['HTTPS'] = 1; $this->assertTrue(env('HTTPS')); $_SERVER['HTTPS'] = 'off'; $this->assertFalse(env('HTTPS')); $_SERVER['HTTPS'] = false; $this->assertFalse(env('HTTPS')); $_SERVER['HTTPS'] = ''; $this->assertFalse(env('HTTPS')); $_SERVER = array(); $_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php'; $this->assertTrue(env('HTTPS')); $_ENV['SCRIPT_URI'] = 'http://domain.test/a/test.php'; $this->assertFalse(env('HTTPS')); $_SERVER = $_ENV = array(); $this->assertFalse(env('TEST_ME')); $_ENV['TEST_ME'] = 'a'; $this->assertEqual(env('TEST_ME'), 'a'); $_SERVER['TEST_ME'] = 'b'; $this->assertEqual(env('TEST_ME'), 'b'); unset($_ENV['TEST_ME']); $this->assertEqual(env('TEST_ME'), 'b'); $_SERVER = $__SERVER; $_ENV = $__ENV; }
testHttpBase method @return void @access public
testEnv
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testUses() { $this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded'); $this->assertFalse(class_exists('Security')); $this->assertFalse(class_exists('Sanitize')); uses('Security', 'Sanitize'); $this->assertTrue(class_exists('Security')); $this->assertTrue(class_exists('Sanitize')); }
test uses() @return void @access public @deprecated
testUses
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testAa() { $result = aa('a', 'b', 'c', 'd'); $expected = array('a' => 'b', 'c' => 'd'); $this->assertEqual($expected, $result); $result = aa('a', 'b', 'c', 'd', 'e'); $expected = array('a' => 'b', 'c' => 'd', 'e' => null); $this->assertEqual($result, $expected); }
Test aa() @return void @access public
testAa
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testAm() { $result = am(array('one', 'two'), 2, 3, 4); $expected = array('one', 'two', 2, 3, 4); $this->assertEqual($result, $expected); $result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5))); $expected = array('one' => array(4, 5),'two' => array('foo')); $this->assertEqual($result, $expected); }
Test am() @return void @access public
testAm
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testCache() { $_cacheDisable = Configure::read('Cache.disable'); if ($this->skipIf($_cacheDisable, 'Cache is disabled, skipping cache() tests. %s')) { return; } Configure::write('Cache.disable', true); $result = cache('basics_test', 'simple cache write'); $this->assertNull($result); $result = cache('basics_test'); $this->assertNull($result); Configure::write('Cache.disable', false); $result = cache('basics_test', 'simple cache write'); $this->assertTrue($result); $this->assertTrue(file_exists(CACHE . 'basics_test')); $result = cache('basics_test'); $this->assertEqual($result, 'simple cache write'); @unlink(CACHE . 'basics_test'); cache('basics_test', 'expired', '+1 second'); sleep(2); $result = cache('basics_test', null, '+1 second'); $this->assertNull($result); Configure::write('Cache.disable', $_cacheDisable); }
test cache() @return void @access public
testCache
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testClearCache() { $cacheOff = Configure::read('Cache.disable'); if ($this->skipIf($cacheOff, 'Cache is disabled, skipping clearCache() tests. %s')) { return; } cache('views' . DS . 'basics_test.cache', 'simple cache write'); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test.cache')); cache('views' . DS . 'basics_test_2.cache', 'simple cache write 2'); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_2.cache')); cache('views' . DS . 'basics_test_3.cache', 'simple cache write 3'); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache')); $result = clearCache(array('basics_test', 'basics_test_2'), 'views', '.cache'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache')); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache')); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache')); $result = clearCache(null, 'views', '.cache'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache')); // Different path from views and with prefix cache('models' . DS . 'basics_test.cache', 'simple cache write'); $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test.cache')); cache('models' . DS . 'basics_test_2.cache', 'simple cache write 2'); $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test_2.cache')); cache('models' . DS . 'basics_test_3.cache', 'simple cache write 3'); $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test_3.cache')); $result = clearCache('basics', 'models', '.cache'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test.cache')); $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test_2.cache')); $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test_3.cache')); // checking if empty files were not removed $emptyExists = file_exists(CACHE . 'views' . DS . 'empty'); if (!$emptyExists) { cache('views' . DS . 'empty', ''); } cache('views' . DS . 'basics_test.php', 'simple cache write'); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test.php')); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'empty')); $result = clearCache(); $this->assertTrue($result); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'empty')); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.php')); if (!$emptyExists) { unlink(CACHE . 'views' . DS . 'empty'); } }
test clearCache() @return void @access public
testClearCache
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testLogError() { @unlink(LOGS . 'error.log'); LogError('Testing LogError() basic function'); LogError("Testing with\nmulti-line\nstring"); $result = file_get_contents(LOGS . 'error.log'); $this->assertPattern('/Error: Testing LogError\(\) basic function/', $result); $this->assertNoPattern("/Error: Testing with\nmulti-line\nstring/", $result); $this->assertPattern('/Error: Testing with multi-line string/', $result); }
test LogError() @return void @access public
testLogError
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testFileExistsInPath() { $this->skipUnless(function_exists('ini_set'), '%s ini_set function not available'); $_includePath = ini_get('include_path'); $path = TMP . 'basics_test'; $folder1 = $path . DS . 'folder1'; $folder2 = $path . DS . 'folder2'; $file1 = $path . DS . 'file1.php'; $file2 = $folder1 . DS . 'file2.php'; $file3 = $folder1 . DS . 'file3.php'; $file4 = $folder2 . DS . 'file4.php'; new Folder($path, true); new Folder($folder1, true); new Folder($folder2, true); touch($file1); touch($file2); touch($file3); touch($file4); ini_set('include_path', $path . PATH_SEPARATOR . $folder1); $this->assertEqual(fileExistsInPath('file1.php'), $file1); $this->assertEqual(fileExistsInPath('file2.php'), $file2); $this->assertEqual(fileExistsInPath('folder1' . DS . 'file2.php'), $file2); $this->assertEqual(fileExistsInPath($file2), $file2); $this->assertEqual(fileExistsInPath('file3.php'), $file3); $this->assertEqual(fileExistsInPath($file4), $file4); $this->assertFalse(fileExistsInPath('file1')); $this->assertFalse(fileExistsInPath('file4.php')); $Folder = new Folder($path); $Folder->delete(); ini_set('include_path', $_includePath); }
test fileExistsInPath() @return void @access public
testFileExistsInPath
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testConvertSlash() { $result = convertSlash('\path\to\location\\'); $expected = '\path\to\location\\'; $this->assertEqual($result, $expected); $result = convertSlash('/path/to/location/'); $expected = 'path_to_location'; $this->assertEqual($result, $expected); }
test convertSlash() @return void @access public
testConvertSlash
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testDebug() { ob_start(); debug('this-is-a-test'); $result = ob_get_clean(); $pattern = '/.*\>(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; $pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s'; $this->assertPattern($pattern, $result); ob_start(); debug('<div>this-is-a-test</div>', true); $result = ob_get_clean(); $pattern = '/.*\>(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; $pattern .= '.*line.*' . (__LINE__ - 4) . '.*&lt;div&gt;this-is-a-test&lt;\/div&gt;.*/s'; $this->assertPattern($pattern, $result); }
test debug() @return void @access public
testDebug
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testPr() { ob_start(); pr('this is a test'); $result = ob_get_clean(); $expected = "<pre>this is a test</pre>"; $this->assertEqual($result, $expected); ob_start(); pr(array('this' => 'is', 'a' => 'test')); $result = ob_get_clean(); $expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>"; $this->assertEqual($result, $expected); }
test pr() @return void @access public
testPr
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testParams() { $this->assertNull(params('weekend')); $this->assertNull(params(array())); $this->assertEqual(params(array('weekend')), array('weekend')); $nested = array(array('weekend')); $this->assertEqual(params($nested), array('weekend')); $multiple = array(array('weekend'), 'jean-luc', 'godard'); $this->assertEqual(params($multiple), $multiple); }
test params() @return void @access public
testParams
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testStripslashesDeepSybase() { $this->skipUnless(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is off'); $this->assertEqual(stripslashes_deep("tes\'t"), "tes\'t"); $nested = array( 'a' => "tes't", 'b' => "tes''t", 'c' => array( 'd' => "tes'''t", 'e' => "tes''''t", array('f' => "tes''t") ), 'g' => "te'''''st" ); $expected = array( 'a' => "tes't", 'b' => "tes't", 'c' => array( 'd' => "tes''t", 'e' => "tes''t", array('f' => "tes't") ), 'g' => "te'''st" ); $this->assertEqual(stripslashes_deep($nested), $expected); }
test stripslashes_deep() with magic_quotes_sybase on @return void @access public
testStripslashesDeepSybase
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function testIfe() { $this->assertEqual(ife(true, 'a', 'b'), 'a'); $this->assertEqual(ife(' ', 'a', 'b'), 'a'); $this->assertEqual(ife('test', 'a', 'b'), 'a'); $this->assertEqual(ife(23, 'a', 'b'), 'a'); $this->assertEqual(ife(array('t' => 'est'), 'a', 'b'), 'a'); $this->assertEqual(ife(false, 'a', 'b'), 'b'); $this->assertEqual(ife(null, 'a', 'b'), 'b'); $this->assertEqual(ife('', 'a', 'b'), 'b'); $this->assertEqual(ife(0, 'a', 'b'), 'b'); $this->assertEqual(ife(array(), 'a', 'b'), 'b'); }
test ife() @return void @access public
testIfe
php
Datawalke/Coordino
cake/tests/cases/basics.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/basics.test.php
MIT
function _invoke(&$controller, $params) { restore_error_handler(); if ($result = parent::_invoke($controller, $params)) { if ($result[0] === 'missingAction') { return $result; } } set_error_handler('simpleTestErrorHandler'); return $controller; }
invoke method @param mixed $controller @param mixed $params @param mixed $missingAction @return void @access protected
_invoke
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function cakeError($filename, $params) { return array($filename, $params); }
cakeError method @param mixed $filename @return void @access public
cakeError
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function index() { return true; }
index method @return void @access public
index
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function add() { return true; }
add method @return void @access public
add
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function admin_add($id = null) { return $id; }
admin_add method @param mixed $id @return void @access public
admin_add
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function display($page = null) { return $page; }
display method @param mixed $page @return void @access public
display
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function index() { return true; }
index method @return void @access public
index
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function _protected() { return true; }
protected method @return void @access protected
_protected
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function redirect() { echo 'this should not be accessible'; }
redirect method overriding @return void @access public
redirect
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function display($page = null) { return $page; }
display method @param mixed $page @return void @access public
display
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function index() { return true; }
index method @return void @access public
index
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function camelCased() { return true; }
camelCased method @return void @access public
camelCased
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function beforeFilter() { if ($this->params['action'] == 'index') { $this->params['action'] = 'view'; } else { $this->params['action'] = 'change'; } $this->params['pass'] = array('changed'); }
beforeFilter method @return void @access public
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function index() { return true; }
index method @return void @access public
index
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function change() { return true; }
change method @return void @access public
change
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function cache_form() { $this->cacheAction = 10; $this->helpers[] = 'Form'; }
test cached forms / tests view object being registered @return void
cache_form
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function index() { return true; }
index method @return void @access public
index
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function startTest() { $this->_get = $_GET; $_GET = array(); $this->_post = $_POST; $this->_files = $_FILES; $this->_server = $_SERVER; $this->_app = Configure::read('App'); Configure::write('App.base', false); Configure::write('App.baseUrl', false); Configure::write('App.dir', 'app'); Configure::write('App.webroot', 'webroot'); $this->_cache = Configure::read('Cache'); Configure::write('Cache.disable', true); $this->_debug = Configure::read('debug'); App::build(App::core()); }
setUp method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function endTest() { $_GET = $this->_get; $_POST = $this->_post; $_FILES = $this->_files; $_SERVER = $this->_server; App::build(); Configure::write('App', $this->_app); Configure::write('Cache', $this->_cache); Configure::write('debug', $this->_debug); }
tearDown method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsWithoutZerosAndEmptyPost() { $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3"); $this->assertIdentical($test['controller'], 'testcontroller'); $this->assertIdentical($test['action'], 'testaction'); $this->assertIdentical($test['pass'][0], 'params1'); $this->assertIdentical($test['pass'][1], 'params2'); $this->assertIdentical($test['pass'][2], 'params3'); $this->assertFalse(!empty($test['form'])); }
testParseParamsWithoutZerosAndEmptyPost method @return void @access public
testParseParamsWithoutZerosAndEmptyPost
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsReturnsPostedData() { $_POST['testdata'] = "My Posted Content"; $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/"); $this->assertTrue($test['form'], "Parsed URL not returning post data"); $this->assertIdentical($test['form']['testdata'], "My Posted Content"); }
testParseParamsReturnsPostedData method @return void @access public
testParseParamsReturnsPostedData
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsWithSingleZero() { $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/testcontroller/testaction/1/0/23"); $this->assertIdentical($test['controller'], 'testcontroller'); $this->assertIdentical($test['action'], 'testaction'); $this->assertIdentical($test['pass'][0], '1'); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]); $this->assertIdentical($test['pass'][2], '23'); }
testParseParamsWithSingleZero method @return void @access public
testParseParamsWithSingleZero
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsWithManySingleZeros() { $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/testcontroller/testaction/0/0/0/0/0/0"); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][0]); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1]); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][2]); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][3]); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][4]); $this->assertPattern('/\\A(?:0)\\z/', $test['pass'][5]); }
testParseParamsWithManySingleZeros method @return void @access public
testParseParamsWithManySingleZeros
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsWithManyZerosInEachSectionOfUrl() { $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/testcontroller/testaction/000/0000/00000/000000/000000/0000000"); $this->assertPattern('/\\A(?:000)\\z/', $test['pass'][0]); $this->assertPattern('/\\A(?:0000)\\z/', $test['pass'][1]); $this->assertPattern('/\\A(?:00000)\\z/', $test['pass'][2]); $this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][3]); $this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][4]); $this->assertPattern('/\\A(?:0000000)\\z/', $test['pass'][5]); }
testParseParamsWithManyZerosInEachSectionOfUrl method @return void @access public
testParseParamsWithManyZerosInEachSectionOfUrl
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() { $Dispatcher =& new Dispatcher(); $test = $Dispatcher->parseParams("/testcontroller/testaction/01/0403/04010/000002/000030/0000400"); $this->assertPattern('/\\A(?:01)\\z/', $test['pass'][0]); $this->assertPattern('/\\A(?:0403)\\z/', $test['pass'][1]); $this->assertPattern('/\\A(?:04010)\\z/', $test['pass'][2]); $this->assertPattern('/\\A(?:000002)\\z/', $test['pass'][3]); $this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]); $this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]); }
testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl method @return void @access public
testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testQueryStringOnRoot() { Router::reload(); Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); $_GET = array('coffee' => 'life', 'sleep' => 'sissies'); $Dispatcher =& new Dispatcher(); $uri = 'posts/home/?coffee=life&sleep=sissies'; $result = $Dispatcher->parseParams($uri); $this->assertPattern('/posts/', $result['controller']); $this->assertPattern('/home/', $result['action']); $this->assertTrue(isset($result['url']['sleep'])); $this->assertTrue(isset($result['url']['coffee'])); $Dispatcher =& new Dispatcher(); $uri = '/?coffee=life&sleep=sissy'; $result = $Dispatcher->parseParams($uri); $this->assertPattern('/pages/', $result['controller']); $this->assertPattern('/display/', $result['action']); $this->assertTrue(isset($result['url']['sleep'])); $this->assertTrue(isset($result['url']['coffee'])); $this->assertEqual($result['url']['coffee'], 'life'); }
testQueryStringOnRoot method @return void @access public
testQueryStringOnRoot
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testFileUploadArrayStructure() { $_FILES = array('data' => array('name' => array( 'File' => array( array('data' => 'cake_mssql_patch.patch'), array('data' => 'controller.diff'), array('data' => ''), array('data' => ''), ), 'Post' => array('attachment' => 'jquery-1.2.1.js'), ), 'type' => array( 'File' => array( array('data' => ''), array('data' => ''), array('data' => ''), array('data' => ''), ), 'Post' => array('attachment' => 'application/x-javascript'), ), 'tmp_name' => array( 'File' => array( array('data' => '/private/var/tmp/phpy05Ywj'), array('data' => '/private/var/tmp/php7MBztY'), array('data' => ''), array('data' => ''), ), 'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'), ), 'error' => array( 'File' => array( array('data' => 0), array('data' => 0), array('data' => 4), array('data' => 4) ), 'Post' => array('attachment' => 0) ), 'size' => array( 'File' => array( array('data' => 6271), array('data' => 350), array('data' => 0), array('data' => 0), ), 'Post' => array('attachment' => 80469) ), )); $Dispatcher =& new Dispatcher(); $result = $Dispatcher->parseParams('/'); $expected = array( 'File' => array( array('data' => array( 'name' => 'cake_mssql_patch.patch', 'type' => '', 'tmp_name' => '/private/var/tmp/phpy05Ywj', 'error' => 0, 'size' => 6271, ), ), array('data' => array( 'name' => 'controller.diff', 'type' => '', 'tmp_name' => '/private/var/tmp/php7MBztY', 'error' => 0, 'size' => 350, )), array('data' => array( 'name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0, )), array('data' => array( 'name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0, )), ), 'Post' => array('attachment' => array( 'name' => 'jquery-1.2.1.js', 'type' => 'application/x-javascript', 'tmp_name' => '/private/var/tmp/phpEwlrIo', 'error' => 0, 'size' => 80469, ))); $this->assertEqual($result['data'], $expected); $_FILES = array( 'data' => array( 'name' => array( 'Document' => array( 1 => array( 'birth_cert' => 'born on.txt', 'passport' => 'passport.txt', 'drivers_license' => 'ugly pic.jpg' ), 2 => array( 'birth_cert' => 'aunt betty.txt', 'passport' => 'betty-passport.txt', 'drivers_license' => 'betty-photo.jpg' ), ), ), 'type' => array( 'Document' => array( 1 => array( 'birth_cert' => 'application/octet-stream', 'passport' => 'application/octet-stream', 'drivers_license' => 'application/octet-stream', ), 2 => array( 'birth_cert' => 'application/octet-stream', 'passport' => 'application/octet-stream', 'drivers_license' => 'application/octet-stream', ) ) ), 'tmp_name' => array( 'Document' => array( 1 => array( 'birth_cert' => '/private/var/tmp/phpbsUWfH', 'passport' => '/private/var/tmp/php7f5zLt', 'drivers_license' => '/private/var/tmp/phpMXpZgT', ), 2 => array( 'birth_cert' => '/private/var/tmp/php5kHZt0', 'passport' => '/private/var/tmp/phpnYkOuM', 'drivers_license' => '/private/var/tmp/php9Rq0P3', ) ) ), 'error' => array( 'Document' => array( 1 => array( 'birth_cert' => 0, 'passport' => 0, 'drivers_license' => 0, ), 2 => array( 'birth_cert' => 0, 'passport' => 0, 'drivers_license' => 0, ) ) ), 'size' => array( 'Document' => array( 1 => array( 'birth_cert' => 123, 'passport' => 458, 'drivers_license' => 875, ), 2 => array( 'birth_cert' => 876, 'passport' => 976, 'drivers_license' => 9783, ) ) ) ) ); $Dispatcher =& new Dispatcher(); $result = $Dispatcher->parseParams('/'); $expected = array( 'Document' => array( 1 => array( 'birth_cert' => array( 'name' => 'born on.txt', 'tmp_name' => '/private/var/tmp/phpbsUWfH', 'error' => 0, 'size' => 123, 'type' => 'application/octet-stream', ), 'passport' => array( 'name' => 'passport.txt', 'tmp_name' => '/private/var/tmp/php7f5zLt', 'error' => 0, 'size' => 458, 'type' => 'application/octet-stream', ), 'drivers_license' => array( 'name' => 'ugly pic.jpg', 'tmp_name' => '/private/var/tmp/phpMXpZgT', 'error' => 0, 'size' => 875, 'type' => 'application/octet-stream', ), ), 2 => array( 'birth_cert' => array( 'name' => 'aunt betty.txt', 'tmp_name' => '/private/var/tmp/php5kHZt0', 'error' => 0, 'size' => 876, 'type' => 'application/octet-stream', ), 'passport' => array( 'name' => 'betty-passport.txt', 'tmp_name' => '/private/var/tmp/phpnYkOuM', 'error' => 0, 'size' => 976, 'type' => 'application/octet-stream', ), 'drivers_license' => array( 'name' => 'betty-photo.jpg', 'tmp_name' => '/private/var/tmp/php9Rq0P3', 'error' => 0, 'size' => 9783, 'type' => 'application/octet-stream', ), ), ) ); $this->assertEqual($result['data'], $expected); $_FILES = array( 'data' => array( 'name' => array('birth_cert' => 'born on.txt'), 'type' => array('birth_cert' => 'application/octet-stream'), 'tmp_name' => array('birth_cert' => '/private/var/tmp/phpbsUWfH'), 'error' => array('birth_cert' => 0), 'size' => array('birth_cert' => 123) ) ); $Dispatcher =& new Dispatcher(); $result = $Dispatcher->parseParams('/'); $expected = array( 'birth_cert' => array( 'name' => 'born on.txt', 'type' => 'application/octet-stream', 'tmp_name' => '/private/var/tmp/phpbsUWfH', 'error' => 0, 'size' => 123 ) ); $this->assertEqual($result['data'], $expected); }
testFileUploadArrayStructure method @return void @access public
testFileUploadArrayStructure
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testGetUrl() { $Dispatcher =& new Dispatcher(); $Dispatcher->base = '/app/webroot/index.php'; $uri = '/app/webroot/index.php/posts/add'; $result = $Dispatcher->getUrl($uri); $expected = 'posts/add'; $this->assertEqual($expected, $result); Configure::write('App.baseUrl', '/app/webroot/index.php'); $uri = '/posts/add'; $result = $Dispatcher->getUrl($uri); $expected = 'posts/add'; $this->assertEqual($expected, $result); $_GET['url'] = array(); Configure::write('App.base', '/control'); $Dispatcher =& new Dispatcher(); $Dispatcher->baseUrl(); $uri = '/control/students/browse'; $result = $Dispatcher->getUrl($uri); $expected = 'students/browse'; $this->assertEqual($expected, $result); $_GET['url'] = array(); $Dispatcher =& new Dispatcher(); $Dispatcher->base = ''; $uri = '/?/home'; $result = $Dispatcher->getUrl($uri); $expected = '?/home'; $this->assertEqual($expected, $result); $_GET['url'] = array(); $Dispatcher =& new Dispatcher(); $Dispatcher->base = '/shop'; $uri = '/shop/fr/pages/shop'; $result = $Dispatcher->getUrl($uri); $expected = 'fr/pages/shop'; $this->assertEqual($expected, $result); }
testGetUrl method @return void @access public
testGetUrl
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlAndWebrootWithModRewrite() { $Dispatcher =& new Dispatcher(); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; $_SERVER['PHP_SELF'] = '/1.2.x.x/app/webroot/index.php'; $result = $Dispatcher->baseUrl(); $expected = '/1.2.x.x'; $this->assertEqual($expected, $result); $expectedWebroot = '/1.2.x.x/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot'; $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; $_SERVER['PHP_SELF'] = '/index.php'; $result = $Dispatcher->baseUrl(); $expected = ''; $this->assertEqual($expected, $result); $expectedWebroot = '/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/test/'; $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/test/webroot/index.php'; $_SERVER['PHP_SELF'] = '/webroot/index.php'; $result = $Dispatcher->baseUrl(); $expected = ''; $this->assertEqual($expected, $result); $expectedWebroot = '/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/some/apps/where'; $_SERVER['SCRIPT_FILENAME'] = '/some/apps/where/app/webroot/index.php'; $_SERVER['PHP_SELF'] = '/some/apps/where/app/webroot/index.php'; $result = $Dispatcher->baseUrl(); $expected = '/some/apps/where'; $this->assertEqual($expected, $result); $expectedWebroot = '/some/apps/where/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.dir', 'auth'); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php'; $_SERVER['PHP_SELF'] = '/demos/auth/webroot/index.php'; $result = $Dispatcher->baseUrl(); $expected = '/demos/auth'; $this->assertEqual($expected, $result); $expectedWebroot = '/demos/auth/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.dir', 'code'); $Dispatcher->base = false; $_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents'; $_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php'; $_SERVER['PHP_SELF'] = '/clients/PewterReport/code/webroot/index.php'; $result = $Dispatcher->baseUrl(); $expected = '/clients/PewterReport/code'; $this->assertEqual($expected, $result); $expectedWebroot = '/clients/PewterReport/code/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); }
testBaseUrlAndWebrootWithModRewrite method @return void @access public
testBaseUrlAndWebrootWithModRewrite
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlwithModRewriteAlias() { $_SERVER['DOCUMENT_ROOT'] = '/home/aplusnur/public_html'; $_SERVER['SCRIPT_FILENAME'] = '/home/aplusnur/cake2/app/webroot/index.php'; $_SERVER['PHP_SELF'] = '/control/index.php'; Configure::write('App.base', '/control'); $Dispatcher =& new Dispatcher(); $result = $Dispatcher->baseUrl(); $expected = '/control'; $this->assertEqual($expected, $result); $expectedWebroot = '/control/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.base', false); Configure::write('App.dir', 'affiliate'); Configure::write('App.webroot', 'newaffiliate'); $_SERVER['DOCUMENT_ROOT'] = '/var/www/abtravaff/html'; $_SERVER['SCRIPT_FILENAME'] = '/var/www/abtravaff/html/newaffiliate/index.php'; $_SERVER['PHP_SELF'] = '/newaffiliate/index.php'; $Dispatcher =& new Dispatcher(); $result = $Dispatcher->baseUrl(); $expected = '/newaffiliate'; $this->assertEqual($expected, $result); $expectedWebroot = '/newaffiliate/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); }
testBaseUrlwithModRewriteAlias method @return void @access public
testBaseUrlwithModRewriteAlias
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlAndWebrootWithBaseUrl() { $Dispatcher =& new Dispatcher(); Configure::write('App.dir', 'app'); Configure::write('App.baseUrl', '/app/webroot/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/app/webroot/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/app/webroot/test.php'); $result = $Dispatcher->baseUrl(); $expected = '/app/webroot/test.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/app/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/app/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/CakeBB/app/webroot/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/CakeBB/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/app/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/CakeBB/app/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/CakeBB/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/index.php'); $result = $Dispatcher->baseUrl(); $expected = '/CakeBB/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/CakeBB/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/dbhauser/index.php'); $_SERVER['DOCUMENT_ROOT'] = '/kunden/homepages/4/d181710652/htdocs/joomla'; $_SERVER['SCRIPT_FILENAME'] = '/kunden/homepages/4/d181710652/htdocs/joomla/dbhauser/index.php'; $result = $Dispatcher->baseUrl(); $expected = '/dbhauser/index.php'; $this->assertEqual($expected, $result); $expectedWebroot = '/dbhauser/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); }
testBaseUrlAndWebrootWithBaseUrl method @return void @access public
testBaseUrlAndWebrootWithBaseUrl
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlWithAppAndWebrootInDirname() { Configure::write('App.baseUrl', '/approval/index.php'); $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/'; $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/approval/index.php'; $Dispatcher =& new Dispatcher(); $result = $Dispatcher->baseUrl(); $this->assertEqual('/approval/index.php', $result); $this->assertEqual('/approval/app/webroot/', $Dispatcher->webroot); Configure::write('App.baseUrl', '/webrootable/index.php'); $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/'; $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/webrootable/index.php'; $Dispatcher =& new Dispatcher(); $result = $Dispatcher->baseUrl(); $this->assertEqual('/webrootable/index.php', $result); $this->assertEqual('/webrootable/app/webroot/', $Dispatcher->webroot); }
Check that a sub-directory containing app|webroot doesn't get mishandled when re-writing is off. @return void
testBaseUrlWithAppAndWebrootInDirname
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlNoRewriteTopLevelIndex() { $Dispatcher =& new Dispatcher(); Configure::write('App.baseUrl', '/index.php'); $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev'; $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/index.php'; $result = $Dispatcher->baseUrl(); $this->assertEqual('/index.php', $result); $this->assertEqual('/app/webroot/', $Dispatcher->webroot); $this->assertEqual('', $Dispatcher->base); }
test baseUrl with no rewrite and using the top level index.php. @return void
testBaseUrlNoRewriteTopLevelIndex
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlNoRewriteWebrootIndex() { $Dispatcher =& new Dispatcher(); Configure::write('App.baseUrl', '/index.php'); $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev/app/webroot'; $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/app/webroot/index.php'; $result = $Dispatcher->baseUrl(); $this->assertEqual('/index.php', $result); $this->assertEqual('/', $Dispatcher->webroot); $this->assertEqual('', $Dispatcher->base); }
test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. @return void
testBaseUrlNoRewriteWebrootIndex
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBaseUrlAndWebrootWithBase() { $Dispatcher =& new Dispatcher(); $Dispatcher->base = '/app'; $result = $Dispatcher->baseUrl(); $expected = '/app'; $this->assertEqual($expected, $result); $expectedWebroot = '/app/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); $Dispatcher->base = ''; $result = $Dispatcher->baseUrl(); $expected = ''; $this->assertEqual($expected, $result); $expectedWebroot = '/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.dir', 'testbed'); $Dispatcher->base = '/cake/testbed/webroot'; $result = $Dispatcher->baseUrl(); $expected = '/cake/testbed/webroot'; $this->assertEqual($expected, $result); $expectedWebroot = '/cake/testbed/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); }
testBaseUrlAndWebrootWithBase method @return void @access public
testBaseUrlAndWebrootWithBase
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testMissingController() { $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl', '/index.php'); $url = 'some_controller/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('missingController', array(array( 'className' => 'SomeControllerController', 'webroot' => '/app/webroot/', 'url' => 'some_controller/home/param:value/param2:value2', 'base' => '/index.php' ))); $this->assertEqual($expected, $controller); }
testMissingController method @return void @access public
testMissingController
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testPrivate() { $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl','/index.php'); $url = 'some_pages/_protected/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('privateAction', array(array( 'className' => 'SomePagesController', 'action' => '_protected', 'webroot' => '/app/webroot/', 'url' => 'some_pages/_protected/param:value/param2:value2', 'base' => '/index.php' ))); $this->assertEqual($controller, $expected); }
testPrivate method @return void @access public
testPrivate
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testMissingAction() { $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl', '/index.php'); $url = 'some_pages/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return'=> 1)); $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'home', 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/home/param:value/param2:value2', 'base' => '/index.php' ))); $this->assertEqual($expected, $controller); $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl','/index.php'); $url = 'some_pages/redirect/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return'=> 1)); $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'redirect', 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/redirect/param:value/param2:value2', 'base' => '/index.php' ))); $this->assertEqual($expected, $controller); }
testMissingAction method @return void @access public
testMissingAction
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testDispatch() { $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl','/index.php'); $url = 'pages/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = 'Pages'; $this->assertEqual($expected, $controller->name); $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); $this->assertIdentical($expected, $controller->passedArgs); Configure::write('App.baseUrl','/pages/index.php'); $url = 'pages/home'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = 'Pages'; $this->assertEqual($expected, $controller->name); $url = 'pages/home/'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertNull($controller->plugin); $this->assertNull($Dispatcher->params['plugin']); $expected = 'Pages'; $this->assertEqual($expected, $controller->name); unset($Dispatcher); $Dispatcher =& new TestDispatcher(); Configure::write('App.baseUrl','/timesheets/index.php'); $url = 'timesheets'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = 'Timesheets'; $this->assertEqual($expected, $controller->name); $url = 'timesheets/'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual('Timesheets', $controller->name); $this->assertEqual('/timesheets/index.php', $Dispatcher->base); $url = 'test_dispatch_pages/camelCased'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual('TestDispatchPages', $controller->name); $url = 'test_dispatch_pages/camelCased/something. .'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['pass'][0], 'something. .', 'Period was chopped off. %s'); }
testDispatch method @return void @access public
testDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testDispatchWithArray() { $Dispatcher =& new TestDispatcher(); $url = 'pages/home/param:value/param2:value2'; $url = array('controller' => 'pages', 'action' => 'display'); $controller = $Dispatcher->dispatch($url, array( 'pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1 )); $expected = 'Pages'; $this->assertEqual($expected, $controller->name); $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); $this->assertIdentical($expected, $controller->passedArgs); $this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here); }
testDispatchWithArray method @return void @access public
testDispatchWithArray
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testDispatchWithGarbageUrl() { Configure::write('App.baseUrl', '/index.php'); $Dispatcher =& new TestDispatcher(); $url = 'http://google.com'; $result = $Dispatcher->dispatch($url); $expected = array('missingController', array(array( 'className' => 'Controller', 'webroot' => '/app/webroot/', 'url' => 'http://google.com', 'base' => '/index.php' ))); $this->assertEqual($expected, $result); }
test that a garbage url doesn't cause errors. @return void
testDispatchWithGarbageUrl
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAdminDispatch() { $_POST = array(); $Dispatcher =& new TestDispatcher(); Configure::write('Routing.prefixes', array('admin')); Configure::write('App.baseUrl','/cake/repo/branches/1.2.x.x/index.php'); $url = 'admin/test_dispatch_pages/index/param:value/param2:value2'; Router::reload(); $Router =& Router::getInstance(); $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->name, 'TestDispatchPages'); $this->assertIdentical($controller->passedArgs, array('param' => 'value', 'param2' => 'value2')); $this->assertTrue($controller->params['admin']); $expected = '/cake/repo/branches/1.2.x.x/index.php/admin/test_dispatch_pages/index/param:value/param2:value2'; $this->assertIdentical($expected, $controller->here); $expected = '/cake/repo/branches/1.2.x.x/index.php'; $this->assertIdentical($expected, $controller->base); }
testAdminDispatch method @return void @access public
testAdminDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testPluginDispatch() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher =& new TestDispatcher(); Router::connect( '/my_plugin/:controller/*', array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display') ); $Dispatcher->base = false; $url = 'my_plugin/some_pages/home/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $result = $Dispatcher->parseParams($url); $expected = array( 'pass' => array('home'), 'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin', 'controller'=> 'some_pages', 'action'=> 'display', 'form'=> null, 'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'), ); ksort($expected); ksort($result); $this->assertEqual($expected, $result); $this->assertIdentical($controller->plugin, 'my_plugin'); $this->assertIdentical($controller->name, 'SomePages'); $this->assertIdentical($controller->params['controller'], 'some_pages'); $this->assertIdentical($controller->passedArgs, array('0' => 'home', 'param'=>'value', 'param2'=>'value2')); $expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2'; $this->assertIdentical($expected, $controller->here); $expected = '/cake/repo/branches/1.2.x.x'; $this->assertIdentical($expected, $controller->base); }
testPluginDispatch method @return void @access public
testPluginDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAutomaticPluginDispatch() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher =& new TestDispatcher(); Router::connect( '/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display') ); $Dispatcher->base = false; $url = 'my_plugin/other_pages/index/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertIdentical($controller->plugin, 'my_plugin'); $this->assertIdentical($controller->name, 'OtherPages'); $this->assertIdentical($controller->action, 'index'); $this->assertIdentical($controller->passedArgs, array('param' => 'value', 'param2' => 'value2')); $expected = '/cake/repo/branches/1.2.x.x/my_plugin/other_pages/index/param:value/param2:value2'; $this->assertIdentical($expected, $controller->here); $expected = '/cake/repo/branches/1.2.x.x'; $this->assertIdentical($expected, $controller->base); }
testAutomaticPluginDispatch method @return void @access public
testAutomaticPluginDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAutomaticPluginControllerDispatch() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; $plugins = App::objects('plugin'); $plugins[] = 'MyPlugin'; $plugins[] = 'ArticlesTest'; $app = App::getInstance(); $app->__objects['plugin'] = $plugins; Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'my_plugin/my_plugin/add/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertIdentical($controller->plugin, 'my_plugin'); $this->assertIdentical($controller->name, 'MyPlugin'); $this->assertIdentical($controller->action, 'add'); $this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2')); Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; // Simulates the Route for a real plugin, installed in APP/plugins Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin')); $plugin = 'MyPlugin'; $pluginUrl = Inflector::underscore($plugin); $url = $pluginUrl; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertIdentical($controller->plugin, 'my_plugin'); $this->assertIdentical($controller->name, 'MyPlugin'); $this->assertIdentical($controller->action, 'index'); $expected = $pluginUrl; $this->assertEqual($controller->params['controller'], $expected); Configure::write('Routing.prefixes', array('admin')); Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'admin/my_plugin/my_plugin/add/5/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['plugin'], 'my_plugin'); $this->assertEqual($controller->params['controller'], 'my_plugin'); $this->assertEqual($controller->params['action'], 'admin_add'); $this->assertEqual($controller->params['pass'], array(5)); $this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2')); $this->assertIdentical($controller->plugin, 'my_plugin'); $this->assertIdentical($controller->name, 'MyPlugin'); $this->assertIdentical($controller->action, 'admin_add'); $expected = array(0 => 5, 'param'=>'value', 'param2'=>'value2'); $this->assertEqual($controller->passedArgs, $expected); Configure::write('Routing.prefixes', array('admin')); Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $controller = $Dispatcher->dispatch('admin/articles_test', array('return' => 1)); $this->assertIdentical($controller->plugin, 'articles_test'); $this->assertIdentical($controller->name, 'ArticlesTest'); $this->assertIdentical($controller->action, 'admin_index'); $expected = array( 'pass'=> array(), 'named' => array(), 'controller' => 'articles_test', 'plugin' => 'articles_test', 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' => array('url' => 'admin/articles_test'), 'return' => 1 ); $this->assertEqual($controller->params, $expected); }
testAutomaticPluginControllerDispatch method @return void @access public
testAutomaticPluginControllerDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAutomaticPluginDispatchWithShortAccess() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; $plugins = App::objects('plugin'); $plugins[] = 'MyPlugin'; $app = App::getInstance(); $app->__objects['plugin'] = $plugins; Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'my_plugin/'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['controller'], 'my_plugin'); $this->assertEqual($controller->params['plugin'], 'my_plugin'); $this->assertEqual($controller->params['action'], 'index'); $this->assertFalse(isset($controller->params['pass'][0])); }
test Plugin dispatching without controller name and using plugin short form instead. @return void @access public
testAutomaticPluginDispatchWithShortAccess
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded() { $loaded = class_exists('TestPluginController', false); if ($this->skipIf($loaded, 'TestPluginController already loaded, this test will always pass, skipping %s')) { return true; } Router::reload(); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); App::objects('plugin', null, false); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'test_plugin/'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['controller'], 'test_plugin'); $this->assertEqual($controller->params['plugin'], 'test_plugin'); $this->assertEqual($controller->params['action'], 'index'); $this->assertFalse(isset($controller->params['pass'][0])); $url = '/test_plugin/tests/index'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['controller'], 'tests'); $this->assertEqual($controller->params['plugin'], 'test_plugin'); $this->assertEqual($controller->params['action'], 'index'); $this->assertFalse(isset($controller->params['pass'][0])); $url = '/test_plugin/tests/index/some_param'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['controller'], 'tests'); $this->assertEqual($controller->params['plugin'], 'test_plugin'); $this->assertEqual($controller->params['action'], 'index'); $this->assertEqual($controller->params['pass'][0], 'some_param'); App::build(); }
test plugin shortcut urls with controllers that need to be loaded, the above test uses a controller that has already been included. @return void
testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAutomaticPluginControllerMissingActionDispatch() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'my_plugin/not_here/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return'=> 1)); $expected = array('missingAction', array(array( 'className' => 'MyPluginController', 'action' => 'not_here', 'webroot' => '/cake/repo/branches/1.2.x.x/', 'url' => '/cake/repo/branches/1.2.x.x/my_plugin/not_here/param:value/param2:value2', 'base' => '/cake/repo/branches/1.2.x.x' ))); $this->assertIdentical($expected, $controller); Router::reload(); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'my_plugin/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return'=> 1)); $expected = array('missingAction', array(array( 'className' => 'MyPluginController', 'action' => 'param:value', 'webroot' => '/cake/repo/branches/1.2.x.x/', 'url' => '/cake/repo/branches/1.2.x.x/my_plugin/param:value/param2:value2', 'base' => '/cake/repo/branches/1.2.x.x' ))); $this->assertIdentical($expected, $controller); }
testAutomaticPluginControllerMissingActionDispatch method @return void @access public
testAutomaticPluginControllerMissingActionDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testPrefixProtection() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); Router::connect('/admin/:controller/:action/*', array('prefix'=>'admin'), array('controller', 'action')); $Dispatcher =& new TestDispatcher(); $Dispatcher->base = false; $url = 'test_dispatch_pages/admin_index/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('privateAction', array(array( 'className' => 'TestDispatchPagesController', 'action' => 'admin_index', 'webroot' => '/cake/repo/branches/1.2.x.x/', 'url' => 'test_dispatch_pages/admin_index/param:value/param2:value2', 'base' => '/cake/repo/branches/1.2.x.x' ))); $this->assertIdentical($expected, $controller); }
testPrefixProtection method @return void @access public
testPrefixProtection
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testTestPluginDispatch() { $Dispatcher =& new TestDispatcher(); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); App::objects('plugin', null, false); Router::reload(); Router::parse('/'); $url = '/test_plugin/tests/index'; $result = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertTrue(class_exists('TestsController')); $this->assertTrue(class_exists('TestPluginAppController')); $this->assertTrue(class_exists('OtherComponentComponent')); $this->assertTrue(class_exists('PluginsComponentComponent')); $this->assertEqual($result->params['controller'], 'tests'); $this->assertEqual($result->params['plugin'], 'test_plugin'); $this->assertEqual($result->params['action'], 'index'); App::build(); }
Test dispatching into the TestPlugin in the test_app @return void @access public
testTestPluginDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testChangingParamsFromBeforeFilter() { $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; $Dispatcher =& new TestDispatcher(); $url = 'some_posts/index/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('missingAction', array(array( 'className' => 'SomePostsController', 'action' => 'view', 'webroot' => '/cake/repo/branches/1.2.x.x/', 'url' => '/cake/repo/branches/1.2.x.x/some_posts/index/param:value/param2:value2', 'base' => '/cake/repo/branches/1.2.x.x' ))); $this->assertEqual($expected, $controller); $url = 'some_posts/something_else/param:value/param2:value2'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = 'SomePosts'; $this->assertEqual($expected, $controller->name); $expected = 'change'; $this->assertEqual($expected, $controller->action); $expected = array('changed'); $this->assertIdentical($expected, $controller->params['pass']); }
testChangingParamsFromBeforeFilter method @return void @access public
testChangingParamsFromBeforeFilter
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAssets() { Router::reload(); $Configure =& Configure::getInstance(); $Configure->__objects = null; App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS), 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $Dispatcher =& new TestDispatcher(); $debug = Configure::read('debug'); Configure::write('debug', 0); ob_start(); $Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css'); $result = ob_get_clean(); $this->assertFalse($result); ob_start(); $Dispatcher->dispatch('theme/test_theme/pdfs'); $result = ob_get_clean(); $this->assertFalse($result); ob_start(); $Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf'); $this->assertEqual($file, $result); $this->assertEqual('this is just a test to load swf file from the theme.', $result); ob_start(); $Dispatcher->dispatch('theme/test_theme/pdfs/theme_test.pdf'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf'); $this->assertEqual($file, $result); $this->assertEqual('this is just a test to load pdf file from the theme.', $result); ob_start(); $Dispatcher->dispatch('theme/test_theme/img/test.jpg'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg'); $this->assertEqual($file, $result); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css'); ob_start(); $Dispatcher->asset('theme/test_theme/css/test_asset.css'); $result = ob_get_clean(); $this->assertEqual('this is the test asset css file', $result); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/theme.js'); ob_start(); $Dispatcher->asset('theme/test_theme/js/theme.js'); $result = ob_get_clean(); $this->assertEqual('root theme js file', $result); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/one/theme_one.js'); ob_start(); $Dispatcher->asset('theme/test_theme/js/one/theme_one.js'); $result = ob_get_clean(); $this->assertEqual('nested theme js file', $result); ob_start(); $Dispatcher->asset('test_plugin/root.js'); $result = ob_get_clean(); $expected = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'root.js'); $this->assertEqual($result, $expected); ob_start(); $Dispatcher->dispatch('test_plugin/flash/plugin_test.swf'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf'); $this->assertEqual($file, $result); $this->assertEqual('this is just a test to load swf file from the plugin.', $result); ob_start(); $Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf'); $this->assertEqual($file, $result); $this->assertEqual('this is just a test to load pdf file from the plugin.', $result); ob_start(); $Dispatcher->asset('test_plugin/js/test_plugin/test.js'); $result = ob_get_clean(); $this->assertEqual('alert("Test App");', $result); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js'); ob_start(); $Dispatcher->asset('test_plugin/js/test_plugin/test.js'); $result = ob_get_clean(); $this->assertEqual('alert("Test App");', $result); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css'); ob_start(); $Dispatcher->asset('test_plugin/css/test_plugin_asset.css'); $result = ob_get_clean(); $this->assertEqual('this is the test plugin asset css file', $result); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif'); ob_start(); $Dispatcher->asset('test_plugin/img/cake.icon.gif'); $result = ob_get_clean(); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif'); $this->assertEqual($file, $result); $Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js'); ob_start(); $Dispatcher->asset('plugin_js/js/plugin_js.js'); $result = ob_get_clean(); $expected = "alert('win sauce');"; $this->assertEqual($result, $expected); $Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js'); ob_start(); $Dispatcher->asset('plugin_js/js/one/plugin_one.js'); $result = ob_get_clean(); $expected = "alert('plugin one nested js file');"; $this->assertEqual($result, $expected); Configure::write('debug', $debug); //reset the header content-type without page can render as plain text. header('Content-type: text/html'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc'); ob_start(); $Dispatcher->asset('test_plugin/css/unknown.extension'); $result = ob_get_clean(); $this->assertEqual('Testing a file with unknown extension to mime mapping.', $result); header('Content-type: text/html'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc'); ob_start(); $Dispatcher->asset('test_plugin/css/theme_one.htc'); $result = ob_get_clean(); $this->assertEqual('htc file', $result); header('Content-type: text/html'); }
testStaticAssets method @return void @access public
testAssets
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testMissingAssetProcessor404() { $Dispatcher =& new TestDispatcher(); Configure::write('Asset.filter', array( 'js' => '', 'css' => null )); $this->assertNoErrors(); ob_start(); $Dispatcher->asset('ccss/cake.generic.css'); $result = ob_get_clean(); $this->assertTrue($Dispatcher->stopped); header('HTTP/1.1 200 Ok'); }
test that missing asset processors trigger a 404 with no response body. @return void
testMissingAssetProcessor404
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testAssetFilterForThemeAndPlugins() { $Dispatcher =& new TestDispatcher(); Configure::write('Asset.filter', array( 'js' => '', 'css' => '' )); $Dispatcher->asset('theme/test_theme/ccss/cake.generic.css'); $this->assertTrue($Dispatcher->stopped); $Dispatcher->stopped = false; $Dispatcher->asset('theme/test_theme/cjs/debug_kit.js'); $this->assertTrue($Dispatcher->stopped); $Dispatcher->stopped = false; $Dispatcher->asset('test_plugin/ccss/cake.generic.css'); $this->assertTrue($Dispatcher->stopped); $Dispatcher->stopped = false; $Dispatcher->asset('test_plugin/cjs/debug_kit.js'); $this->assertTrue($Dispatcher->stopped); $Dispatcher->stopped = false; $Dispatcher->asset('css/ccss/debug_kit.css'); $this->assertFalse($Dispatcher->stopped); $Dispatcher->stopped = false; $Dispatcher->asset('js/cjs/debug_kit.js'); $this->assertFalse($Dispatcher->stopped); }
test that asset filters work for theme and plugin assets @return void
testAssetFilterForThemeAndPlugins
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testFullPageCachingDispatch() { Configure::write('Cache.disable', false); Configure::write('Cache.check', true); Configure::write('debug', 2); $_POST = array(); $_SERVER['PHP_SELF'] = '/'; Router::reload(); Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index')); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS), ), true); $dispatcher =& new TestDispatcher(); $dispatcher->base = false; $url = '/'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); $dispatcher->base = false; $url = 'test_cached_pages/index'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); $url = 'TestCachedPages/index'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); $url = 'TestCachedPages/test_nocache_tags'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); $url = 'test_cached_pages/view/param/param'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); $url = 'test_cached_pages/view/foo:bar/value:goo'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); $this->assertTrue(file_exists($filename)); unlink($filename); }
testFullPageCachingDispatch method @return void @access public
testFullPageCachingDispatch
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testCachedRegisteringViewObject() { Configure::write('Cache.disable', false); Configure::write('Cache.check', true); Configure::write('debug', 2); $_POST = array(); $_SERVER['PHP_SELF'] = '/'; Router::reload(); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $dispatcher =& new TestDispatcher(); $dispatcher->base = false; $url = 'test_cached_pages/cache_form'; ob_start(); $dispatcher->dispatch($url); $out = ob_get_clean(); ClassRegistry::flush(); ob_start(); $dispatcher->cached($url); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); @unlink($filename); ClassRegistry::flush(); }
test that cached() registers a view and un-registers it. Tests that helpers using ClassRegistry::getObject('view'); don't fail @return void
testCachedRegisteringViewObject
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testHttpMethodOverrides() { Router::reload(); Router::mapResources('Posts'); $_SERVER['REQUEST_METHOD'] = 'POST'; $dispatcher =& new Dispatcher(); $dispatcher->base = false; $result = $dispatcher->parseParams('/posts'); $expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array(), 'url' => array()); $this->assertEqual($result, $expected); $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; $result = $dispatcher->parseParams('/posts/5'); $expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array()); $this->assertEqual($result, $expected); unset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = $dispatcher->parseParams('/posts/5'); $expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'form' => array(), 'url' => array()); $this->assertEqual($result, $expected); $_POST['_method'] = 'PUT'; $result = $dispatcher->parseParams('/posts/5'); $expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array()); $this->assertEqual($result, $expected); $_POST['_method'] = 'POST'; $_POST['data'] = array('Post' => array('title' => 'New Post')); $_POST['extra'] = 'data'; $_SERVER = array(); $result = $dispatcher->parseParams('/posts'); $expected = array( 'pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array('extra' => 'data'), 'data' => array('Post' => array('title' => 'New Post')), 'url' => array() ); $this->assertEqual($result, $expected); unset($_POST['_method']); }
testHttpMethodOverrides method @return void @access public
testHttpMethodOverrides
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testBasePathInjection() { $self = $_SERVER['PHP_SELF']; $_SERVER['PHP_SELF'] = urldecode( "/index.php/%22%3E%3Ch1%20onclick=%22alert('xss');%22%3Eheya%3C/h1%3E" ); $dispatcher =& new Dispatcher(); $result = $dispatcher->baseUrl(); $expected = '/index.php/h1 onclick=alert(xss);heya'; $this->assertEqual($result, $expected); }
Tests that invalid characters cannot be injected into the application base path. @return void @access public
testBasePathInjection
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testEnvironmentDetection() { $dispatcher =& new Dispatcher(); $environments = array( 'IIS' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php?', 'server' => 'IIS'), 'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_HOST' => 'localhost', 'argv' => array(), 'argc' => 0), 'reload' => true, 'path' => '' ), 'No rewrite with path' => array( 'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'argv' => array('/posts/add'), 'argc' => 1), 'reload' => false, 'path' => '/posts/add' ), 'No rewrite sub dir 1' => array( 'GET' => array(), 'SERVER' => array('QUERY_STRING' => '', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0), 'reload' => false, 'path' => '' ), 'No rewrite sub dir 1 with path' => array( 'GET' => array('/posts/add' => ''), 'SERVER' => array('QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'URL' => '/index.php?/posts/add', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'argv' => array('/posts/add'), 'argc' => 1), 'reload' => false, 'path' => '/posts/add' ), 'No rewrite sub dir 2' => array( 'App' => array('base' => false, 'baseUrl' => '/site/index.php?', 'dir' => 'app', 'webroot' => 'webroot', 'server' => 'IIS'), 'GET' => array(), 'POST' => array(), 'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REQUEST_URI' => '/site/index.php', 'URL' => '/site/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array(), 'argc' => 0), 'reload' => false, 'path' => '' ), 'No rewrite sub dir 2 with path' => array( 'GET' => array('/posts/add' => ''), 'SERVER' => array('SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/site/index.php?/posts/add', 'URL' => '/site/index.php?/posts/add', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', 'argv' => array('/posts/add'), 'argc' => 1), 'reload' => false, 'path' => '/posts/add' ) ), 'Apache' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot'), 'SERVER' => array( 'SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0 ), 'reload' => true, 'path' => '' ), 'No rewrite with path' => array( 'SERVER' => array( 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0), 'reload' => false, 'path' => '/posts/add' ), 'GET Request at base domain' => array( 'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'), 'SERVER' => array( 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php' ), 'GET' => array('a' => 'b'), 'POST' => array(), 'reload' => true, 'path' => '', 'urlParams' => array('a' => 'b'), 'environment' => array('CGI_MODE' => false) ), 'New CGI no mod_rewrite' => array( 'App' => array('base' => false, 'baseUrl' => '/limesurvey20/index.php', 'dir' => 'app', 'webroot' => 'webroot'), 'SERVER' => array( 'DOCUMENT_ROOT' => '/home/.sites/110/site313/web', 'PATH_INFO' => '/installations', 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'PHPRC' => '/home/.sites/110/site313', 'QUERY_STRING' => '', 'REQUEST_URI' => '/limesurvey20/index.php/installations', 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'SCRIPT_NAME' => '/limesurvey20/index.php', 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', 'PHP_SELF' => '/limesurvey20/index.php/installations', 'CGI_MODE' => true ), 'GET' => array(), 'POST' => array(), 'reload' => true, 'path' => '/installations', 'urlParams' => array(), 'environment' => array('CGI_MODE' => true) ) ) ); $backup = $this->__backupEnvironment(); foreach ($environments as $name => $env) { foreach ($env as $descrip => $settings) { if ($settings['reload']) { $this->__reloadEnvironment(); } $this->__loadEnvironment($settings); $this->assertEqual($dispatcher->uri(), $settings['path'], "%s on environment: {$name}, on setting: {$descrip}"); if (isset($settings['urlParams'])) { $this->assertEqual($_GET, $settings['urlParams'], "%s on environment: {$name}, on setting: {$descrip}"); } if (isset($settings['environment'])) { foreach ($settings['environment'] as $key => $val) { $this->assertEqual(env($key), $val, "%s on key {$key} on environment: {$name}, on setting: {$descrip}"); } } } } $this->__loadEnvironment(array_merge(array('reload' => true), $backup)); }
testEnvironmentDetection method @return void @access public
testEnvironmentDetection
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function testTrailingSlash() { $_POST = array(); $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher =& new TestDispatcher(); Router::connect('/myalias/:action/*', array('controller' => 'my_controller', 'action' => null)); $Dispatcher->base = false; $url = 'myalias/'; //Fails $controller = $Dispatcher->dispatch($url, array('return' => 1)); $result = $Dispatcher->parseParams($url); $this->assertEqual('index', $result['action']); $url = 'myalias'; //Passes $controller = $Dispatcher->dispatch($url, array('return' => 1)); $result = $Dispatcher->parseParams($url); $this->assertEqual('index', $result['action']); }
Tests that the Dispatcher does not return an empty action @return void @access public
testTrailingSlash
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function __backupEnvironment() { return array( 'App' => Configure::read('App'), 'GET' => $_GET, 'POST' => $_POST, 'SERVER'=> $_SERVER ); }
backupEnvironment method @return void @access private
__backupEnvironment
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function __reloadEnvironment() { foreach ($_GET as $key => $val) { unset($_GET[$key]); } foreach ($_POST as $key => $val) { unset($_POST[$key]); } foreach ($_SERVER as $key => $val) { unset($_SERVER[$key]); } Configure::write('App', array()); }
reloadEnvironment method @return void @access private
__reloadEnvironment
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function __loadEnvironment($env) { if ($env['reload']) { $this->__reloadEnvironment(); } if (isset($env['App'])) { Configure::write('App', $env['App']); } if (isset($env['GET'])) { foreach ($env['GET'] as $key => $val) { $_GET[$key] = $val; } } if (isset($env['POST'])) { foreach ($env['POST'] as $key => $val) { $_POST[$key] = $val; } } if (isset($env['SERVER'])) { foreach ($env['SERVER'] as $key => $val) { $_SERVER[$key] = $val; } } }
loadEnvironment method @param mixed $env @return void @access private
__loadEnvironment
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function __cachePath($here) { $path = $here; if ($here == '/') { $path = 'home'; } $path = strtolower(Inflector::slug($path)); $filename = CACHE . 'views' . DS . $path . '.php'; if (!file_exists($filename)) { $filename = CACHE . 'views' . DS . $path . '_index.php'; } return $filename; }
cachePath method @param mixed $her @return string @access private
__cachePath
php
Datawalke/Coordino
cake/tests/cases/dispatcher.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/dispatcher.test.php
MIT
function stderr($string) { $this->stderr .= rtrim($string, ' '); }
stderr method @return void @access public
stderr
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function stdout($string, $newline = true) { if ($newline) { $this->stdout .= rtrim($string, ' ') . "\n"; } else { $this->stdout .= rtrim($string, ' '); } }
stdout method @return void @access public
stdout
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function getShell($plugin = null) { return $this->_getShell($plugin); }
getShell @param mixed $plugin @return mixed @access public
getShell
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function _getShell($plugin = null) { if (isset($this->TestShell)) { return $this->TestShell; } return parent::_getShell($plugin); }
_getShell @param mixed $plugin @return mixed @access protected
_getShell
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function setUp() { App::build(array( 'plugins' => array( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS ), 'shells' => array( CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS ) ), true); }
setUp method @return void @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testParseParams() { $Dispatcher =& new TestShellDispatcher(); $params = array( '/cake/1.2.x.x/cake/console/cake.php', 'bake', '-app', 'new', '-working', '/var/www/htdocs' ); $expected = array( 'app' => 'new', 'webroot' => 'webroot', 'working' => '/var/www/htdocs/new', 'root' => '/var/www/htdocs' ); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array('cake.php'); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'app'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH), ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( 'cake.php', '-app', 'new', ); $expected = array( 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH) ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( './cake.php', 'bake', '-app', 'new', '-working', '/cake/1.2.x.x/cake/console' ); $expected = array( 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH) ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( './console/cake.php', 'bake', '-app', 'new', '-working', '/cake/1.2.x.x/cake' ); $expected = array( 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH) ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( './console/cake.php', 'bake', '-app', 'new', '-dry', '-working', '/cake/1.2.x.x/cake' ); $expected = array( 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH), 'dry' => 1 ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( './console/cake.php', '-working', '/cake/1.2.x.x/cake', 'schema', 'run', 'create', '-dry', '-f', '-name', 'DbAcl' ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'app'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH), 'dry' => 1, 'f' => 1, 'name' => 'DbAcl' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $expected = array('./console/cake.php', 'schema', 'run', 'create'); $this->assertEqual($expected, $Dispatcher->args); $params = array( '/cake/1.2.x.x/cake/console/cake.php', '-working', '/cake/1.2.x.x/app', 'schema', 'run', 'create', '-dry', '-name', 'DbAcl' ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => '/cake/1.2.x.x/app', 'root' => '/cake/1.2.x.x', 'dry' => 1, 'name' => 'DbAcl' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create'); $this->assertEqual($expected, $Dispatcher->args); $params = array( 'cake.php', '-working', 'C:/wamp/www/cake/app', 'bake', '-app', 'C:/wamp/www/apps/cake/app', ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( 'cake.php', '-working', 'C:\wamp\www\cake\app', 'bake', '-app', 'C:\wamp\www\apps\cake\app', ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( 'cake.php', '-working', 'C:\wamp\www\apps', 'bake', '-app', 'cake\app', '-url', 'http://example.com/some/url/with/a/path' ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake', 'url' => 'http://example.com/some/url/with/a/path' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( '/home/amelo/dev/cake-common/cake/console/cake.php', '-root', '/home/amelo/dev/lsbu-vacancy', '-working', '/home/amelo/dev/lsbu-vacancy', '-app', 'app', ); $expected = array( 'app' => 'app', 'webroot' => 'webroot', 'working' => '/home/amelo/dev/lsbu-vacancy/app', 'root' => '/home/amelo/dev/lsbu-vacancy', ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( 'cake.php', '-working', 'D:\www', 'bake', 'my_app', ); $expected = array( 'working' => 'D:\www', 'app' => 'www', 'root' => 'D:', 'webroot' => 'webroot' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); $params = array( 'cake.php', '-working', 'D:\ ', 'bake', 'my_app', ); $expected = array( 'working' => '.', 'app' => 'D:', 'root' => '.', 'webroot' => 'webroot' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); }
testParseParams method @return void @access public
testParseParams
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testBuildPaths() { $Dispatcher =& new TestShellDispatcher(); $result = $Dispatcher->shellPaths; $expected = array( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'vendors' . DS . 'shells' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS . 'vendors' . DS . 'shells' . DS, APP . 'vendors' . DS . 'shells' . DS, VENDORS . 'shells' . DS, CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS, ); $this->assertIdentical(array_diff($result, $expected), array()); $this->assertIdentical(array_diff($expected, $result), array()); }
testBuildPaths method @return void @access public
testBuildPaths
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testGetShell() { $this->skipIf(class_exists('SampleShell'), '%s SampleShell Class already loaded'); $this->skipIf(class_exists('ExampleShell'), '%s ExampleShell Class already loaded'); $Dispatcher =& new TestShellDispatcher(); $Dispatcher->shell = 'sample'; $Dispatcher->shellName = 'Sample'; $Dispatcher->shellClass = 'SampleShell'; $result = $Dispatcher->getShell(); $this->assertIsA($result, 'SampleShell'); $Dispatcher =& new TestShellDispatcher(); $Dispatcher->shell = 'example'; $Dispatcher->shellName = 'Example'; $Dispatcher->shellClass = 'ExampleShell'; $result = $Dispatcher->getShell('test_plugin'); $this->assertIsA($result, 'ExampleShell'); }
Verify loading of (plugin-) shells @return void @access public
testGetShell
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testDispatchShellWithMain() { Mock::generate('Shell', 'MockWithMainShell', array('main', '_secret')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('initialize'); $Shell->expectOnce('loadTasks'); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('initdb')); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('help'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', 'help'); $result = $Dispatcher->dispatch(); $this->assertNull($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectNever('hr'); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', 'hr'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('hr')); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', 'dispatch'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('dispatch')); $Shell = new MockWithMainShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', 'idontexist'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('idontexist')); $Shell = new MockWithMainShell(); $Shell->expectNever('startup'); $Shell->expectNever('main'); $Shell->expectNever('_secret'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main', '_secret'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); }
Verify correct dispatch of Shell subclasses with a main method @return void @access public
testDispatchShellWithMain
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testDispatchShellWithoutMain() { Mock::generate('Shell', 'MockWithoutMainShell', array('initDb', '_secret')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectOnce('initialize'); $Shell->expectOnce('loadTasks'); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectOnce('startup'); $Shell->expectOnce('initDb'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Shell->expectNever('hr'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'hr'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $this->assertEqual($Dispatcher->args, array('hr')); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'dispatch'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainShell(); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'idontexist'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainShell(); $Shell->expectNever('startup'); $Shell->expectNever('_secret'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', '_secret'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); }
Verify correct dispatch of Shell subclasses without a main method @return void @access public
testDispatchShellWithoutMain
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testDispatchNotAShellWithMain() { Mock::generate('Object', 'MockWithMainNotAShell', array('main', 'initialize', 'loadTasks', 'startup', '_secret')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWithMainNotAShell(); $Shell->setReturnValue('main', true); $Shell->expectNever('initialize'); $Shell->expectNever('loadTasks'); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithMainNotAShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('initdb')); $Shell = new MockWithMainNotAShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a', 'hr'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('hr')); $Shell = new MockWithMainNotAShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a', 'dispatch'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('dispatch')); $Shell = new MockWithMainNotAShell(); $Shell->setReturnValue('main', true); $Shell->expectOnce('startup'); $Shell->expectOnce('main'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a', 'idontexist'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array('idontexist')); $Shell = new MockWithMainNotAShell(); $Shell->expectNever('startup'); $Shell->expectNever('main'); $Shell->expectNever('_secret'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_with_main_not_a', '_secret'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); }
Verify correct dispatch of custom classes with a main method @return void @access public
testDispatchNotAShellWithMain
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testDispatchNotAShellWithoutMain() { Mock::generate('Object', 'MockWithoutMainNotAShell', array('initDb', 'initialize', 'loadTasks', 'startup', '_secret')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWithoutMainNotAShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('initialize'); $Shell->expectNever('loadTasks'); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainNotAShell(); $Shell->setReturnValue('initDb', true); $Shell->expectOnce('startup'); $Shell->expectOnce('initDb'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithoutMainNotAShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a', 'hr'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainNotAShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a', 'dispatch'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainNotAShell(); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a', 'idontexist'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainNotAShell(); $Shell->expectNever('startup'); $Shell->expectNever('_secret'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main_not_a', '_secret'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); }
Verify correct dispatch of custom classes without a main method @return void @access public
testDispatchNotAShellWithoutMain
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testDispatchTask() { Mock::generate('Shell', 'MockWeekShell', array('main')); Mock::generate('Shell', 'MockOnSundayTask', array('execute')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWeekShell(); $Shell->expectOnce('initialize'); $Shell->expectOnce('loadTasks'); $Shell->expectNever('startup'); $Shell->expectNever('main'); $Task = new MockOnSundayTask(); $Task->setReturnValue('execute', true); $Task->expectOnce('initialize'); $Task->expectOnce('loadTasks'); $Task->expectOnce('startup'); $Task->expectOnce('execute'); $Shell->MockOnSunday =& $Task; $Shell->taskNames = array('MockOnSunday'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_week', 'mock_on_sunday'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWeekShell(); $Task = new MockOnSundayTask(); $Task->expectNever('execute'); $Task->expectOnce('help'); $Shell->MockOnSunday =& $Task; $Shell->taskNames = array('MockOnSunday'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_week', 'mock_on_sunday', 'help'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); }
Verify that a task is called instead of the shell if the first arg equals the name of the task @return void @access public
testDispatchTask
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testShiftArgs() { $Dispatcher =& new TestShellDispatcher(); $Dispatcher->args = array('a', 'b', 'c'); $this->assertEqual($Dispatcher->shiftArgs(), 'a'); $this->assertIdentical($Dispatcher->args, array('b', 'c')); $Dispatcher->args = array('a' => 'b', 'c', 'd'); $this->assertEqual($Dispatcher->shiftArgs(), 'b'); $this->assertIdentical($Dispatcher->args, array('c', 'd')); $Dispatcher->args = array('a', 'b' => 'c', 'd'); $this->assertEqual($Dispatcher->shiftArgs(), 'a'); $this->assertIdentical($Dispatcher->args, array('b' => 'c', 'd')); $Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c'); $this->assertEqual($Dispatcher->shiftArgs(), 'a'); $this->assertIdentical($Dispatcher->args, array(0 => 'b', 1 => 'c')); $Dispatcher->args = array(); $this->assertNull($Dispatcher->shiftArgs()); $this->assertIdentical($Dispatcher->args, array()); }
Verify shifting of arguments @return void @access public
testShiftArgs
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT
function testHelpCommand() { $Dispatcher =& new TestShellDispatcher(); $expected = "/example \[.*TestPlugin, TestPluginTwo.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/welcome \[.*TestPluginTwo.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/acl \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/api \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/bake \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/console \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/i18n \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/schema \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/testsuite \[.*CORE.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); $expected = "/sample \[.*test_app.*\]/"; $this->assertPattern($expected, $Dispatcher->stdout); }
testHelpCommand method @return void @access public
testHelpCommand
php
Datawalke/Coordino
cake/tests/cases/console/cake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/cake.test.php
MIT