mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch 'local/svn/1.2.x.x' into 1.2
This commit is contained in:
commit
97e55d7bdf
17 changed files with 673 additions and 175 deletions
|
@ -362,8 +362,8 @@ if (!function_exists('array_combine')) {
|
||||||
*/
|
*/
|
||||||
function env($key) {
|
function env($key) {
|
||||||
if ($key == 'HTTPS') {
|
if ($key == 'HTTPS') {
|
||||||
if (isset($_SERVER) && !empty($_SERVER)) {
|
if (isset($_SERVER['HTTPS'])) {
|
||||||
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on');
|
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
|
||||||
}
|
}
|
||||||
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
|
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -515,10 +515,10 @@ class Dispatcher extends Object {
|
||||||
parse_str($uri[1], $_GET);
|
parse_str($uri[1], $_GET);
|
||||||
}
|
}
|
||||||
$uri = $uri[0];
|
$uri = $uri[0];
|
||||||
} elseif (empty($uri) && is_string(env('QUERY_STRING'))) {
|
} else {
|
||||||
$uri = env('QUERY_STRING');
|
$uri = env('QUERY_STRING');
|
||||||
}
|
}
|
||||||
if (strpos($uri, 'index.php') !== false) {
|
if (is_string($uri) && strpos($uri, 'index.php') !== false) {
|
||||||
list(, $uri) = explode('index.php', $uri, 2);
|
list(, $uri) = explode('index.php', $uri, 2);
|
||||||
}
|
}
|
||||||
if (empty($uri) || $uri == '/' || $uri == '//') {
|
if (empty($uri) || $uri == '/' || $uri == '//') {
|
||||||
|
|
|
@ -491,7 +491,6 @@ class EmailComponent extends Object{
|
||||||
$this->__header[] = 'Content-Type: text/html; charset=' . $this->charset;
|
$this->__header[] = 'Content-Type: text/html; charset=' . $this->charset;
|
||||||
} elseif ($this->sendAs === 'both') {
|
} elseif ($this->sendAs === 'both') {
|
||||||
$this->__header[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
|
$this->__header[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
|
||||||
$this->__header[] = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->__header[] = 'Content-Transfer-Encoding: 7bit';
|
$this->__header[] = 'Content-Transfer-Encoding: 7bit';
|
||||||
|
@ -504,12 +503,16 @@ class EmailComponent extends Object{
|
||||||
*/
|
*/
|
||||||
function __formatMessage($message) {
|
function __formatMessage($message) {
|
||||||
if (!empty($this->attachments)) {
|
if (!empty($this->attachments)) {
|
||||||
$prefix = array(
|
$prefix = array('--' . $this->__boundary);
|
||||||
'--' . $this->__boundary,
|
if ($this->sendAs === 'text') {
|
||||||
'Content-Type: text/plain; charset=' . $this->charset,
|
$prefix[] = 'Content-Type: text/plain; charset=' . $this->charset;
|
||||||
'Content-Transfer-Encoding: 7bit',
|
} elseif ($this->sendAs === 'html') {
|
||||||
''
|
$prefix[] = 'Content-Type: text/html; charset=' . $this->charset;
|
||||||
);
|
} elseif ($this->sendAs === 'both') {
|
||||||
|
$prefix[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
|
||||||
|
}
|
||||||
|
$prefix[] = 'Content-Transfer-Encoding: 7bit';
|
||||||
|
$prefix[] = '';
|
||||||
$message = array_merge($prefix, $message);
|
$message = array_merge($prefix, $message);
|
||||||
}
|
}
|
||||||
return $message;
|
return $message;
|
||||||
|
|
|
@ -481,9 +481,11 @@ class DboMysql extends DboMysqlBase {
|
||||||
|
|
||||||
if ($parent != null) {
|
if ($parent != null) {
|
||||||
return $parent;
|
return $parent;
|
||||||
} elseif ($data === null || (is_array($data) && empty($data))) {
|
}
|
||||||
|
if ($data === null || (is_array($data) && empty($data))) {
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
} elseif ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
|
}
|
||||||
|
if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
|
||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
if (empty($column)) {
|
if (empty($column)) {
|
||||||
|
|
|
@ -200,9 +200,8 @@ class DboSource extends DataSource {
|
||||||
if ($this->error) {
|
if ($this->error) {
|
||||||
$this->showQuery($sql);
|
$this->showQuery($sql);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return $this->_result;
|
|
||||||
}
|
}
|
||||||
|
return $this->_result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* DataSource Query abstraction
|
* DataSource Query abstraction
|
||||||
|
@ -1515,7 +1514,7 @@ class DboSource extends DataSource {
|
||||||
return $join;
|
return $join;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the an SQL calculation, i.e. COUNT() or MAX()
|
* Returns an SQL calculation, i.e. COUNT() or MAX()
|
||||||
*
|
*
|
||||||
* @param model $model
|
* @param model $model
|
||||||
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
|
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
|
||||||
|
@ -1843,9 +1842,9 @@ class DboSource extends DataSource {
|
||||||
if (array_keys($value) === array_values(array_keys($value))) {
|
if (array_keys($value) === array_values(array_keys($value))) {
|
||||||
$count = count($value);
|
$count = count($value);
|
||||||
if ($count === 1) {
|
if ($count === 1) {
|
||||||
$data = $this->name($key) . ' = (';
|
$data = $this->__quoteFields($key) . ' = (';
|
||||||
} else {
|
} else {
|
||||||
$data = $this->name($key) . ' IN (';
|
$data = $this->__quoteFields($key) . ' IN (';
|
||||||
}
|
}
|
||||||
if ($quoteValues || strpos($value[0], '-!') !== 0) {
|
if ($quoteValues || strpos($value[0], '-!') !== 0) {
|
||||||
if (is_object($model)) {
|
if (is_object($model)) {
|
||||||
|
@ -1908,7 +1907,9 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$type = (is_object($model) ? $model->getColumnType($key) : null);
|
$type = (is_object($model) ? $model->getColumnType($key) : null);
|
||||||
|
|
||||||
$null = ($value === null || (is_array($value) && empty($value)));
|
$null = ($value === null || (is_array($value) && empty($value)));
|
||||||
|
|
||||||
if (strtolower($operator) === 'not') {
|
if (strtolower($operator) === 'not') {
|
||||||
|
@ -1917,6 +1918,7 @@ class DboSource extends DataSource {
|
||||||
);
|
);
|
||||||
return $data[0];
|
return $data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = $this->value($value, $type);
|
$value = $this->value($value, $type);
|
||||||
|
|
||||||
if ($key !== '?') {
|
if ($key !== '?') {
|
||||||
|
@ -1957,6 +1959,7 @@ class DboSource extends DataSource {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "{$key} {$operator} {$value}";
|
return "{$key} {$operator} {$value}";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -460,8 +460,6 @@ class Router extends Object {
|
||||||
|
|
||||||
if (isset($names[$key])) {
|
if (isset($names[$key])) {
|
||||||
$out[$names[$key]] = $_this->stripEscape($found);
|
$out[$names[$key]] = $_this->stripEscape($found);
|
||||||
} elseif (isset($names[$key]) && empty($names[$key]) && empty($out[$names[$key]])) {
|
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
$argOptions['context'] = array('action' => $out['action'], 'controller' => $out['controller']);
|
$argOptions['context'] = array('action' => $out['action'], 'controller' => $out['controller']);
|
||||||
extract($_this->getArgs($found, $argOptions));
|
extract($_this->getArgs($found, $argOptions));
|
||||||
|
@ -1082,7 +1080,7 @@ class Router extends Object {
|
||||||
if (isset($params[$key])) {
|
if (isset($params[$key])) {
|
||||||
$string = $params[$key];
|
$string = $params[$key];
|
||||||
unset($params[$key]);
|
unset($params[$key]);
|
||||||
} else {
|
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
|
||||||
$key = $key . '/';
|
$key = $key . '/';
|
||||||
}
|
}
|
||||||
$out = str_replace(':' . $key, $string, $out);
|
$out = str_replace(':' . $key, $string, $out);
|
||||||
|
@ -1200,7 +1198,7 @@ class Router extends Object {
|
||||||
$paths = Router::getPaths();
|
$paths = Router::getPaths();
|
||||||
|
|
||||||
if (!empty($paths['base']) && stristr($url, $paths['base'])) {
|
if (!empty($paths['base']) && stristr($url, $paths['base'])) {
|
||||||
$url = preg_replace('/' . preg_quote($paths['base'], '/') . '/', '', $url, 1);
|
$url = preg_replace('/^' . preg_quote($paths['base'], '/') . '/', '', $url, 1);
|
||||||
}
|
}
|
||||||
$url = '/' . $url;
|
$url = '/' . $url;
|
||||||
|
|
||||||
|
@ -1245,7 +1243,7 @@ class Router extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function stripPlugin($base, $plugin) {
|
function stripPlugin($base, $plugin = null) {
|
||||||
if ($plugin != null) {
|
if ($plugin != null) {
|
||||||
$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
|
$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
|
||||||
$base = str_replace('//', '', $base);
|
$base = str_replace('//', '', $base);
|
||||||
|
@ -1258,7 +1256,6 @@ class Router extends Object {
|
||||||
}
|
}
|
||||||
return $base;
|
return $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip escape characters from parameter values.
|
* Strip escape characters from parameter values.
|
||||||
*
|
*
|
||||||
|
|
|
@ -226,11 +226,12 @@ class PaginatorHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$dir = 'asc';
|
$dir = 'asc';
|
||||||
$sortKey = $this->sortKey($options['model']);
|
$sortKey = $this->sortKey($options['model']);
|
||||||
$isSorted = ($sortKey === $key);
|
$isSorted = ($sortKey === $key || $sortKey === $this->defaultModel() . '.' . $key);
|
||||||
|
|
||||||
if ($isSorted && $this->sortDir($options['model']) === 'asc') {
|
if ($isSorted && $this->sortDir($options['model']) === 'asc') {
|
||||||
$dir = 'desc';
|
$dir = 'desc';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($title) && array_key_exists($dir, $title)) {
|
if (is_array($title) && array_key_exists($dir, $title)) {
|
||||||
$title = $title[$dir];
|
$title = $title[$dir];
|
||||||
}
|
}
|
||||||
|
@ -490,11 +491,15 @@ class PaginatorHelper extends AppHelper {
|
||||||
$end = $params['page'] + ($modulus - $params['page']) + 1;
|
$end = $params['page'] + ($modulus - $params['page']) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($first && $start > (int)$first) {
|
if ($first) {
|
||||||
|
if ($start > (int)$first) {
|
||||||
if ($start == $first + 1) {
|
if ($start == $first + 1) {
|
||||||
$out .= $this->first($first, array('tag' => $tag, 'after' => $separator));
|
$out .= $this->first($first, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
|
||||||
} else {
|
} else {
|
||||||
$out .= $this->first($first, array('tag' => $tag));
|
$out .= $this->first($first, array('tag' => $tag, 'separator' => $separator));
|
||||||
|
}
|
||||||
|
} elseif ($start == 2) {
|
||||||
|
$out .= $this->Html->tag($tag, $this->link(1, array('page' => 1), $options)) . $separator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,11 +525,15 @@ class PaginatorHelper extends AppHelper {
|
||||||
|
|
||||||
$out .= $after;
|
$out .= $after;
|
||||||
|
|
||||||
if ($last && $end <= $params['pageCount'] - (int)$last) {
|
if ($last) {
|
||||||
|
if ($end <= $params['pageCount'] - (int)$last) {
|
||||||
if ($end + 1 == $params['pageCount']) {
|
if ($end + 1 == $params['pageCount']) {
|
||||||
$out .= $this->last($last, array('tag' => $tag, 'before' => $separator));
|
$out .= $this->last($last, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
|
||||||
} else {
|
} else {
|
||||||
$out .= $this->last($last, array('tag' => $tag));
|
$out .= $this->last($last, array('tag' => $tag, 'separator' => $separator));
|
||||||
|
}
|
||||||
|
} elseif ($end == $params['pageCount'] - 1) {
|
||||||
|
$out .= $separator . $this->Html->tag($tag, $this->link($params['pageCount'], array('page' => $params['pageCount']), $options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,10 +142,10 @@ class SessionHelper extends CakeSession {
|
||||||
$out = $flash['message'];
|
$out = $flash['message'];
|
||||||
} else {
|
} else {
|
||||||
$view =& ClassRegistry::getObject('view');
|
$view =& ClassRegistry::getObject('view');
|
||||||
list($tmpLayout, $tmpVars, $tmpTitle) = array($view->layout, $view->viewVars, $view->pageTitle);
|
list($tmpVars, $tmpTitle) = array($view->viewVars, $view->pageTitle);
|
||||||
list($view->layout, $view->viewVars, $view->pageTitle) = array($flash['layout'], $flash['params'], '');
|
list($view->viewVars, $view->pageTitle) = array($flash['params'], '');
|
||||||
$out = $view->renderLayout($flash['message']);
|
$out = $view->renderLayout($flash['message'], $flash['layout']);
|
||||||
list($view->layout, $view->viewVars, $view->pageTitle) = array($tmpLayout, $tmpVars, $tmpTitle);
|
list($view->viewVars, $view->pageTitle) = array($tmpVars, $tmpTitle);
|
||||||
}
|
}
|
||||||
echo($out);
|
echo($out);
|
||||||
parent::del('Message.' . $key);
|
parent::del('Message.' . $key);
|
||||||
|
|
|
@ -277,17 +277,20 @@ class TextHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$pos = strpos(strtolower($text), strtolower($phrase));
|
$pos = strpos(strtolower($text), strtolower($phrase));
|
||||||
|
|
||||||
$startPos = 0;
|
$startPos = 0;
|
||||||
if ($pos > $radius) {
|
if ($pos > $radius) {
|
||||||
$startPos = $pos - $radius;
|
$startPos = $pos - $radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
$textLen = strlen($text);
|
$textLen = strlen($text);
|
||||||
|
|
||||||
$endPos = $pos + $phraseLen + $radius;
|
$endPos = $pos + $phraseLen + $radius;
|
||||||
if ($endPos >= $textLen) {
|
if ($endPos >= $textLen) {
|
||||||
$endPos = $textLen;
|
$endPos = $textLen;
|
||||||
}
|
}
|
||||||
$excerpt = substr($text, $startPos, $endPos - $startPos);
|
|
||||||
|
|
||||||
|
$excerpt = substr($text, $startPos, $endPos - $startPos);
|
||||||
if ($startPos != 0) {
|
if ($startPos != 0) {
|
||||||
$excerpt = substr_replace($excerpt, $ending, 0, $phraseLen);
|
$excerpt = substr_replace($excerpt, $ending, 0, $phraseLen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,6 +417,10 @@ class View extends Object {
|
||||||
*/
|
*/
|
||||||
function renderLayout($content_for_layout, $layout = null) {
|
function renderLayout($content_for_layout, $layout = null) {
|
||||||
$layoutFileName = $this->_getLayoutFileName($layout);
|
$layoutFileName = $this->_getLayoutFileName($layout);
|
||||||
|
if (empty($layoutFileName)) {
|
||||||
|
return $this->output;
|
||||||
|
}
|
||||||
|
|
||||||
$debug = '';
|
$debug = '';
|
||||||
|
|
||||||
if (isset($this->viewVars['cakeDebug']) && Configure::read() > 2) {
|
if (isset($this->viewVars['cakeDebug']) && Configure::read() > 2) {
|
||||||
|
@ -892,7 +896,7 @@ class View extends Object {
|
||||||
$paths = array();
|
$paths = array();
|
||||||
$viewPaths = Configure::read('viewPaths');
|
$viewPaths = Configure::read('viewPaths');
|
||||||
|
|
||||||
if ($plugin !== null) {
|
if (!empty($plugin)) {
|
||||||
$count = count($viewPaths);
|
$count = count($viewPaths);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
|
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
|
||||||
|
|
|
@ -94,12 +94,29 @@ class BasicsTest extends CakeTestCase {
|
||||||
|
|
||||||
$_SERVER = $_ENV = array();
|
$_SERVER = $_ENV = array();
|
||||||
|
|
||||||
|
$this->assertFalse(env('HTTPS'));
|
||||||
|
|
||||||
$_SERVER['HTTPS'] = 'on';
|
$_SERVER['HTTPS'] = 'on';
|
||||||
$this->assertTrue(env('HTTPS'));
|
$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';
|
$_SERVER['HTTPS'] = 'off';
|
||||||
$this->assertFalse(env('HTTPS'));
|
$this->assertFalse(env('HTTPS'));
|
||||||
|
|
||||||
|
$_SERVER['HTTPS'] = false;
|
||||||
|
$this->assertFalse(env('HTTPS'));
|
||||||
|
|
||||||
|
$_SERVER['HTTPS'] = '';
|
||||||
|
$this->assertFalse(env('HTTPS'));
|
||||||
|
|
||||||
$_SERVER = array();
|
$_SERVER = array();
|
||||||
|
|
||||||
$_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php';
|
$_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php';
|
||||||
|
|
|
@ -106,7 +106,7 @@ class TestTaskTest extends CakeTestCase {
|
||||||
'16. setAction($action)',
|
'16. setAction($action)',
|
||||||
'17. validate()',
|
'17. validate()',
|
||||||
'18. validateErrors()'
|
'18. validateErrors()'
|
||||||
)A
|
)
|
||||||
);
|
);
|
||||||
$this->Shell->expectAt(1, 'out', $expected);
|
$this->Shell->expectAt(1, 'out', $expected);
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,8 @@ MSGBLOC;
|
||||||
|
|
||||||
// TODO: better test for format of message sent?
|
// TODO: better test for format of message sent?
|
||||||
$this->Controller->EmailTest->sendAs = 'both';
|
$this->Controller->EmailTest->sendAs = 'both';
|
||||||
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $message);
|
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"', $message);
|
||||||
|
|
||||||
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
||||||
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
||||||
}
|
}
|
||||||
|
@ -412,10 +413,11 @@ HTMLBLOC;
|
||||||
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
||||||
|
|
||||||
$this->Controller->EmailTest->sendAs = 'both';
|
$this->Controller->EmailTest->sendAs = 'both';
|
||||||
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $header);
|
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"', $header);
|
||||||
$expect .= '--alt-' . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n";
|
$expect .= '--alt-' . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n";
|
||||||
$expect .= '--alt-' . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n";
|
$expect .= '--alt-' . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n";
|
||||||
$expect = '<pre>' . $expect . '--alt---' . "\n\n" . '</pre>';
|
$expect = '<pre>' . $expect . '--alt---' . "\n\n" . '</pre>';
|
||||||
|
|
||||||
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
||||||
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
||||||
|
|
||||||
|
@ -556,6 +558,66 @@ TEXTBLOC;
|
||||||
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
|
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
|
||||||
$this->assertEqual(trim($matches[1]), $subject);
|
$this->assertEqual(trim($matches[1]), $subject);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testSendAsIsNotIgnoredIfAttachmentsPresent() {
|
||||||
|
$this->Controller->EmailTest->reset();
|
||||||
|
$this->Controller->EmailTest->to = 'postmaster@localhost';
|
||||||
|
$this->Controller->EmailTest->from = 'noreply@example.com';
|
||||||
|
$this->Controller->EmailTest->subject = 'Attachment Test';
|
||||||
|
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
|
||||||
|
$this->Controller->EmailTest->template = null;
|
||||||
|
$this->Controller->EmailTest->delivery = 'debug';
|
||||||
|
$this->Controller->EmailTest->attachments = array(__FILE__);
|
||||||
|
$body = '<p>This is the body of the message</p>';
|
||||||
|
|
||||||
|
$this->Controller->EmailTest->sendAs = 'html';
|
||||||
|
$this->assertTrue($this->Controller->EmailTest->send($body));
|
||||||
|
$msg = $this->Controller->Session->read('Message.email.message');
|
||||||
|
$this->assertNoPattern('/text\/plain/', $msg);
|
||||||
|
$this->assertPattern('/text\/html/', $msg);
|
||||||
|
|
||||||
|
$this->Controller->EmailTest->sendAs = 'text';
|
||||||
|
$this->assertTrue($this->Controller->EmailTest->send($body));
|
||||||
|
$msg = $this->Controller->Session->read('Message.email.message');
|
||||||
|
$this->assertPattern('/text\/plain/', $msg);
|
||||||
|
$this->assertNoPattern('/text\/html/', $msg);
|
||||||
|
|
||||||
|
$this->Controller->EmailTest->sendAs = 'both';
|
||||||
|
$this->assertTrue($this->Controller->EmailTest->send($body));
|
||||||
|
$msg = $this->Controller->Session->read('Message.email.message');
|
||||||
|
|
||||||
|
$this->assertNoPattern('/text\/plain/', $msg);
|
||||||
|
$this->assertNoPattern('/text\/html/', $msg);
|
||||||
|
$this->assertPattern('/multipart\/alternative/', $msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testNoDoubleNewlinesInHeaders() {
|
||||||
|
$this->Controller->EmailTest->reset();
|
||||||
|
$this->Controller->EmailTest->to = 'postmaster@localhost';
|
||||||
|
$this->Controller->EmailTest->from = 'noreply@example.com';
|
||||||
|
$this->Controller->EmailTest->subject = 'Attachment Test';
|
||||||
|
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
|
||||||
|
$this->Controller->EmailTest->template = null;
|
||||||
|
$this->Controller->EmailTest->delivery = 'debug';
|
||||||
|
$body = '<p>This is the body of the message</p>';
|
||||||
|
|
||||||
|
$this->Controller->EmailTest->sendAs = 'both';
|
||||||
|
$this->assertTrue($this->Controller->EmailTest->send($body));
|
||||||
|
$msg = $this->Controller->Session->read('Message.email.message');
|
||||||
|
|
||||||
|
$this->assertNoPattern('/\n\nContent-Transfer-Encoding/', $msg);
|
||||||
|
$this->assertPattern('/\nContent-Transfer-Encoding/', $msg);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* testReset method
|
* testReset method
|
||||||
*
|
*
|
||||||
|
|
|
@ -2133,7 +2133,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->conditions(array('score' => array(2=>1, 2, 10)));
|
$result = $this->testDb->conditions(array('score' => array(2=>1, 2, 10)));
|
||||||
$expected = " WHERE `score` IN (1, 2, 10)";
|
$expected = " WHERE score IN (1, 2, 10)";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->conditions("Aro.rght = Aro.lft + 1.1");
|
$result = $this->testDb->conditions("Aro.rght = Aro.lft + 1.1");
|
||||||
|
@ -2385,7 +2385,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->conditions(array('score' => array(1, 2, 10)));
|
$result = $this->testDb->conditions(array('score' => array(1, 2, 10)));
|
||||||
$expected = " WHERE `score` IN (1, 2, 10)";
|
$expected = " WHERE score IN (1, 2, 10)";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->conditions(array('score' => array()));
|
$result = $this->testDb->conditions(array('score' => array()));
|
||||||
|
@ -2476,7 +2476,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)),
|
'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)),
|
||||||
'Enrollment.yearcompleted >' => '0')
|
'Enrollment.yearcompleted >' => '0')
|
||||||
);
|
);
|
||||||
$this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(`level_of_education_id` IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result);
|
$this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(level_of_education_id IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result);
|
||||||
|
|
||||||
$result = $this->testDb->conditions(array('id <>' => '8'));
|
$result = $this->testDb->conditions(array('id <>' => '8'));
|
||||||
$this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result);
|
$this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result);
|
||||||
|
@ -2495,16 +2495,24 @@ class DboSourceTest extends CakeTestCase {
|
||||||
"Listing.description LIKE" => "%term_2%"
|
"Listing.description LIKE" => "%term_2%"
|
||||||
);
|
);
|
||||||
$result = $this->testDb->conditions($conditions);
|
$result = $this->testDb->conditions($conditions);
|
||||||
$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
|
$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" .
|
||||||
|
" ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" .
|
||||||
|
" ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah'));
|
$result = $this->testDb->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah'));
|
||||||
$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'";
|
$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->testDb->conditions(array(
|
||||||
|
'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah')
|
||||||
|
));
|
||||||
|
$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')";
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76));
|
$conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76));
|
||||||
$result = $this->testDb->conditions($conditions);
|
$result = $this->testDb->conditions($conditions);
|
||||||
$expected = " WHERE `id` IN (2, 5, 6, 9, 12, 45, 78, 43, 76)";
|
$expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$conditions = array('title' => 'user(s)');
|
$conditions = array('title' => 'user(s)');
|
||||||
|
|
|
@ -299,7 +299,7 @@ class RouterTest extends CakeTestCase {
|
||||||
$result = Router::normalize('/recipe/recipes/add');
|
$result = Router::normalize('/recipe/recipes/add');
|
||||||
$this->assertEqual($result, '/recipe/recipes/add');
|
$this->assertEqual($result, '/recipe/recipes/add');
|
||||||
|
|
||||||
Router::setRequestInfo(array(array(), array('base' => 'us')));
|
Router::setRequestInfo(array(array(), array('base' => '/us')));
|
||||||
$result = Router::normalize('/us/users/logout/');
|
$result = Router::normalize('/us/users/logout/');
|
||||||
$this->assertEqual($result, '/users/logout');
|
$this->assertEqual($result, '/users/logout');
|
||||||
|
|
||||||
|
@ -309,6 +309,22 @@ class RouterTest extends CakeTestCase {
|
||||||
$result = Router::normalize('/cake_12/users/logout/');
|
$result = Router::normalize('/cake_12/users/logout/');
|
||||||
$this->assertEqual($result, '/users/logout');
|
$this->assertEqual($result, '/users/logout');
|
||||||
|
|
||||||
|
Router::reload();
|
||||||
|
$_back = Configure::read('App.baseUrl');
|
||||||
|
Configure::write('App.baseUrl', '/');
|
||||||
|
|
||||||
|
Router::setRequestInfo(array(array(), array('base' => '/')));
|
||||||
|
$result = Router::normalize('users/login');
|
||||||
|
$this->assertEqual($result, '/users/login');
|
||||||
|
Configure::write('App.baseUrl', $_back);
|
||||||
|
|
||||||
|
Router::reload();
|
||||||
|
Router::setRequestInfo(array(array(), array('base' => 'beer')));
|
||||||
|
$result = Router::normalize('beer/admin/beers_tags/add');
|
||||||
|
$this->assertEqual($result, '/admin/beers_tags/add');
|
||||||
|
|
||||||
|
$result = Router::normalize('/admin/beers_tags/add');
|
||||||
|
$this->assertEqual($result, '/admin/beers_tags/add');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testUrlGeneration method
|
* testUrlGeneration method
|
||||||
|
@ -1036,6 +1052,28 @@ class RouterTest extends CakeTestCase {
|
||||||
$result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2'));
|
$result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2'));
|
||||||
$expected = '/beheer/posts/index/0?var=test&var2=test2';
|
$expected = '/beheer/posts/index/0?var=test&var2=test2';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
Configure::write('Routing.admin', 'admin');
|
||||||
|
$paths = Configure::read('pluginPaths');
|
||||||
|
Configure::write('pluginPaths', array(
|
||||||
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
||||||
|
));
|
||||||
|
Configure::write('__objects.plugin', array('test_plugin'));
|
||||||
|
|
||||||
|
Router::reload();
|
||||||
|
Router::setRequestInfo(array(
|
||||||
|
array('admin' => true, 'controller' => 'controller', 'action' => 'action',
|
||||||
|
'form' => array(), 'url' => array(), 'plugin' => null),
|
||||||
|
array('base' => '/', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array(),
|
||||||
|
'argSeparator' => ':', 'namedArgs' => array())
|
||||||
|
));
|
||||||
|
Router::parse('/');
|
||||||
|
|
||||||
|
$result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index'));
|
||||||
|
$expected = '/admin/test_plugin';
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
Configure::write('pluginPaths', $paths);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testExtensionParsingSetting method
|
* testExtensionParsingSetting method
|
||||||
|
@ -1617,5 +1655,20 @@ class RouterTest extends CakeTestCase {
|
||||||
$expected = '/test/test_another_action/locale:badness';
|
$expected = '/test/test_another_action/locale:badness';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testStripPlugin
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testStripPlugin() {
|
||||||
|
$pluginName = 'forums';
|
||||||
|
$url = 'example.com/' . $pluginName . '/';
|
||||||
|
$expected = 'example.com';
|
||||||
|
|
||||||
|
$this->assertEqual(Router::stripPlugin($url, $pluginName), $expected);
|
||||||
|
$this->assertEqual(Router::stripPlugin($url), $url);
|
||||||
|
$this->assertEqual(Router::stripPlugin($url, null), $url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -117,8 +117,10 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
||||||
$result = $this->Paginator->prev('prev', array('update' => 'theList', 'indicator' => 'loading', 'url' => array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span'));
|
$result = $this->Paginator->prev('prev', array('update' => 'theList', 'indicator' => 'loading', 'url' => array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span'));
|
||||||
$expected = '<span class="disabled">prev</span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'span' => array('class' => 'disabled'), 'prev', '/span'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSortLinks method
|
* testSortLinks method
|
||||||
|
@ -135,24 +137,60 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->Paginator->options(array('url' => array('param')));
|
$this->Paginator->options(array('url' => array('param')));
|
||||||
$result = $this->Paginator->sort('title');
|
$result = $this->Paginator->sort('title');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc">Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->sort('date');
|
$result = $this->Paginator->sort('date');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:date\/direction:desc">Date<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc'),
|
||||||
|
'Date',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->numbers(array('modulus'=> '2', 'url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list'));
|
$result = $this->Paginator->numbers(array('modulus'=> '2', 'url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list'));
|
||||||
$this->assertPattern('/\/projects\/sort\/page:2/', $result);
|
$this->assertPattern('/\/projects\/sort\/page:2/', $result);
|
||||||
$this->assertPattern('/<script type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*Event.observe/', $result);
|
$this->assertPattern('/<script type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*Event.observe/', $result);
|
||||||
|
|
||||||
$result = $this->Paginator->sort('TestTitle', 'title');
|
$result = $this->Paginator->sort('TestTitle', 'title');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc">TestTitle<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
|
||||||
|
'TestTitle',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc">ascending<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
|
||||||
|
'ascending',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['sort'] = 'title';
|
$this->Paginator->params['paging']['Article']['options']['sort'] = 'title';
|
||||||
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc">descending<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc'),
|
||||||
|
'descending',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||||
|
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||||
|
$result = $this->Paginator->sort('title');
|
||||||
|
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc">Title<\/a>$/', $result);
|
||||||
|
|
||||||
|
|
||||||
|
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||||
|
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||||
|
$result = $this->Paginator->sort('title');
|
||||||
|
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc">Title<\/a>$/', $result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSortLinksUsingDotNotation method
|
* testSortLinksUsingDotNotation method
|
||||||
|
@ -170,16 +208,30 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||||
$result = $this->Paginator->sort('Title','Article.title');
|
$result = $this->Paginator->sort('Title','Article.title');
|
||||||
$this->assertPattern('/\/accounts\/index\/page:1\/sort:Article.title\/direction:asc">Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||||
$result = $this->Paginator->sort('Title','Article.title');
|
$result = $this->Paginator->sort('Title','Article.title');
|
||||||
$this->assertPattern('/\/accounts\/index\/page:1\/sort:Article.title\/direction:desc">Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
|
$this->Paginator->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
|
||||||
$result = $this->Paginator->sort('title');
|
$result = $this->Paginator->sort('title');
|
||||||
$this->assertPattern('/\/accounts\/index\/page:1\/sort:title\/direction:asc">Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/page:1/sort:title/direction:asc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSortKey method
|
* testSortKey method
|
||||||
|
@ -188,7 +240,6 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSortKey() {
|
function testSortKey() {
|
||||||
|
|
||||||
$result = $this->Paginator->sortKey(null, array(
|
$result = $this->Paginator->sortKey(null, array(
|
||||||
'order' => array('Article.title' => 'desc'
|
'order' => array('Article.title' => 'desc'
|
||||||
)));
|
)));
|
||||||
|
@ -280,8 +331,12 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
Router::parse('/admin/users');
|
Router::parse('/admin/users');
|
||||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/href="\/admin\/users\/index\/page:2"/', $result);
|
'a' => array('href' => '/admin/users/index/page:2'),
|
||||||
|
'Next',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
Router::reload();
|
Router::reload();
|
||||||
Router::setRequestInfo(array(
|
Router::setRequestInfo(array(
|
||||||
|
@ -291,12 +346,21 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
Router::parse('/');
|
Router::parse('/');
|
||||||
$this->Paginator->options(array('url' => array('param')));
|
$this->Paginator->options(array('url' => array('param')));
|
||||||
$result = $this->Paginator->sort('title');
|
$result = $this->Paginator->sort('title');
|
||||||
$this->assertPattern('/\/admin\/test\/index\/param\/page:1\/sort:title\/direction:asc"\s*>Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/admin/test/index/param/page:1/sort:title/direction:asc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->options(array('url' => array('param')));
|
$this->Paginator->options(array('url' => array('param')));
|
||||||
$result = $this->Paginator->sort('Title', 'Article.title');
|
$result = $this->Paginator->sort('Title', 'Article.title');
|
||||||
$this->assertPattern('/\/admin\/test\/index\/param\/page:1\/sort:Article.title\/direction:asc"\s*>Title<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/admin/test/index/param/page:1/sort:Article.title/direction:asc'),
|
||||||
|
'Title',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testUrlGeneration method
|
* testUrlGeneration method
|
||||||
|
@ -306,8 +370,12 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testUrlGeneration() {
|
function testUrlGeneration() {
|
||||||
$result = $this->Paginator->sort('controller');
|
$result = $this->Paginator->sort('controller');
|
||||||
$this->assertPattern('/\/page:1\//', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/\/sort:controller\//', $result);
|
'a' => array('href' => '/index/page:1/sort:controller/direction:asc'),
|
||||||
|
'Controller',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->url();
|
$result = $this->Paginator->url();
|
||||||
$this->assertEqual($result, '/index/page:1');
|
$this->assertEqual($result, '/index/page:1');
|
||||||
|
@ -351,16 +419,28 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->sort('name', null, array('url' => $options));
|
$result = $this->Paginator->sort('name', null, array('url' => $options));
|
||||||
$expected = '<a href="/members/posts/index/page:2/sort:name/direction:asc">Name</a>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'a' => array('href' => '/members/posts/index/page:2/sort:name/direction:asc'),
|
||||||
|
'Name',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected, true);
|
||||||
|
|
||||||
$result = $this->Paginator->next('next', array('url' => $options));
|
$result = $this->Paginator->next('next', array('url' => $options));
|
||||||
$expected = '<a href="/members/posts/index/page:3">next</a>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'a' => array('href' => '/members/posts/index/page:3'),
|
||||||
|
'next',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('prev', array('url' => $options));
|
$result = $this->Paginator->prev('prev', array('url' => $options));
|
||||||
$expected = '<a href="/members/posts/index/page:1">prev</a>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'a' => array('href' => '/members/posts/index/page:1'),
|
||||||
|
'prev',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$options = array('members' => true, 'controller' => 'posts', 'order' => array('name' => 'desc'));
|
$options = array('members' => true, 'controller' => 'posts', 'order' => array('name' => 'desc'));
|
||||||
$result = $this->Paginator->url($options);
|
$result = $this->Paginator->url($options);
|
||||||
|
@ -432,28 +512,54 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||||
);
|
);
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$expected = '<div class="disabled"><< Previous</div>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'div' => array('class' => 'disabled'),
|
||||||
|
'<< Previous',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'span'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'span'));
|
||||||
$expected = '<span class="disabled"><< Previous</span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'span' => array('class' => 'disabled'),
|
||||||
|
'<< Previous',
|
||||||
|
'/span'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/href="\/index\/page:1"/', $result);
|
'a' => array('href' => '/index/page:1'),
|
||||||
|
'<< Previous',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/href="\/index\/page:3"/', $result);
|
'a' => array('href' => '/index/page:3'),
|
||||||
|
'Next',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
||||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/index/page:1'),
|
||||||
|
'<< Previous',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
||||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/index/page:1'),
|
||||||
|
'preg:/<< Previous/',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging'] = array('Client' => array(
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||||
|
@ -462,13 +568,28 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>');
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>');
|
||||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
$expected = array(
|
||||||
|
'<div',
|
||||||
|
'<strong>Disabled</strong>',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
|
||||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
$expected = array(
|
||||||
|
'<div',
|
||||||
|
'<strong>Disabled</strong>',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false));
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false));
|
||||||
$this->assertPattern('/^<div><strong>Disabled<\/strong><\/div>$/', $result);
|
$expected = array(
|
||||||
|
'<div',
|
||||||
|
'<strong', 'Disabled', '/strong',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging'] = array('Client' => array(
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||||
|
@ -479,10 +600,20 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$this->assertPattern('/\/sort:Client.name\/direction:DESC"/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC'),
|
||||||
|
'<< Previous',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected, true);
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$this->assertPattern('/\/sort:Client.name\/direction:DESC"/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC'),
|
||||||
|
'Next',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging'] = array('Client' => array(
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2,
|
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2,
|
||||||
|
@ -520,11 +651,16 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$result = $this->Paginator->next('Next', array('model' => 'Client'));
|
$result = $this->Paginator->next('Next', array('model' => 'Client'));
|
||||||
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/href="\/index\/page:2"/', $result); // These is passed.
|
'a' => array('href' => '/index/page:2'), 'Next', '/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
|
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
|
||||||
$this->assertPattern('/^<div>No Next<\/div>$/', $result);
|
$expected = array(
|
||||||
|
'<div', 'No Next', '/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testGenericLinks method
|
* testGenericLinks method
|
||||||
|
@ -534,24 +670,30 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testGenericLinks() {
|
function testGenericLinks() {
|
||||||
$result = $this->Paginator->link('Sort by title on page 5', array('sort' => 'title', 'page' => 5, 'direction' => 'desc'));
|
$result = $this->Paginator->link('Sort by title on page 5', array('sort' => 'title', 'page' => 5, 'direction' => 'desc'));
|
||||||
$this->assertPattern('/^<a href=".+"[^<>]*>Sort by title on page 5<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/\/page:5/', $result);
|
'a' => array('href' => '/index/page:5/sort:title/direction:desc'),
|
||||||
$this->assertPattern('/\/sort:title/', $result);
|
'Sort by title on page 5',
|
||||||
$this->assertPattern('/\/direction:desc/', $result);
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
||||||
$result = $this->Paginator->link('Sort by title', array('sort' => 'title', 'direction' => 'desc'));
|
$result = $this->Paginator->link('Sort by title', array('sort' => 'title', 'direction' => 'desc'));
|
||||||
$this->assertPattern('/^<a href=".+"[^<>]*>Sort by title<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/\/page:2/', $result);
|
'a' => array('href' => '/index/page:2/sort:title/direction:desc'),
|
||||||
$this->assertPattern('/\/sort:title/', $result);
|
'Sort by title',
|
||||||
$this->assertPattern('/\/direction:desc/', $result);
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['options']['page'] = 4;
|
$this->Paginator->params['paging']['Article']['options']['page'] = 4;
|
||||||
$result = $this->Paginator->link('Sort by title on page 4', array('sort' => 'Article.title', 'direction' => 'desc'));
|
$result = $this->Paginator->link('Sort by title on page 4', array('sort' => 'Article.title', 'direction' => 'desc'));
|
||||||
$this->assertPattern('/^<a href=".+"[^<>]*>Sort by title on page 4<\/a>$/', $result);
|
$expected = array(
|
||||||
$this->assertPattern('/\/page:4/', $result);
|
'a' => array('href' => '/index/page:4/sort:Article.title/direction:desc'),
|
||||||
$this->assertPattern('/\/sort:Article.title/', $result);
|
'Sort by title on page 4',
|
||||||
$this->assertPattern('/\/direction:desc/', $result);
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Tests generation of generic links with preset options
|
* Tests generation of generic links with preset options
|
||||||
|
@ -725,6 +867,66 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$result = $this->Paginator->numbers();
|
$result = $this->Paginator->numbers();
|
||||||
$expected = '<span><a href="/index/page:1/sort:Client.name/direction:DESC">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3/sort:Client.name/direction:DESC">3</a></span> | <span><a href="/index/page:4/sort:Client.name/direction:DESC">4</a></span>';
|
$expected = '<span><a href="/index/page:1/sort:Client.name/direction:DESC">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3/sort:Client.name/direction:DESC">3</a></span> | <span><a href="/index/page:4/sort:Client.name/direction:DESC">4</a></span>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
|
'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
|
||||||
|
'defaults' => array('limit' => 10),
|
||||||
|
'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array()))
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
|
||||||
|
$expected = array(
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
|
||||||
|
'...',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array('class' => 'current')), '4895', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
|
'page' => 3, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
|
||||||
|
'defaults' => array('limit' => 10),
|
||||||
|
'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array()))
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
|
||||||
|
$expected = array(
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array('class' => 'current')), '3', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
|
||||||
|
'...',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
|
||||||
|
' | ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - '));
|
||||||
|
$expected = array(
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||||
|
' - ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
|
||||||
|
' - ',
|
||||||
|
array('span' => array('class' => 'current')), '3', '/span',
|
||||||
|
' - ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
|
||||||
|
'...',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
|
||||||
|
' - ',
|
||||||
|
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testFirstAndLast method
|
* testFirstAndLast method
|
||||||
|
@ -750,28 +952,71 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->Paginator->first();
|
$result = $this->Paginator->first();
|
||||||
$expected = '<span><a href="/index/page:1"><< first</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'<span',
|
||||||
|
'a' => array('href' => '/index/page:1'),
|
||||||
|
'<< first',
|
||||||
|
'/a',
|
||||||
|
'/span'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->first('<<', array('tag' => 'li'));
|
$result = $this->Paginator->first('<<', array('tag' => 'li'));
|
||||||
$expected = '<li><a href="/index/page:1"><<</a></li>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'<li',
|
||||||
|
'a' => array('href' => '/index/page:1'),
|
||||||
|
'<<',
|
||||||
|
'/a',
|
||||||
|
'/li'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last();
|
$result = $this->Paginator->last();
|
||||||
$expected = '<span><a href="/index/page:15">last >></a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'<span',
|
||||||
|
'a' => array('href' => '/index/page:15'),
|
||||||
|
'last >>',
|
||||||
|
'/a',
|
||||||
|
'/span'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last(1);
|
$result = $this->Paginator->last(1);
|
||||||
$expected = '...<span><a href="/index/page:15">15</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'...',
|
||||||
|
'<span',
|
||||||
|
'a' => array('href' => '/index/page:15'),
|
||||||
|
'15',
|
||||||
|
'/a',
|
||||||
|
'/span'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last(2);
|
$result = $this->Paginator->last(2);
|
||||||
$expected = '...<span><a href="/index/page:14">14</a></span> | <span><a href="/index/page:15">15</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'...',
|
||||||
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:14')), '14', '/a',
|
||||||
|
'/span',
|
||||||
|
' | ',
|
||||||
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:15')), '15', '/a',
|
||||||
|
'/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last(2, array('tag' => 'li'));
|
$result = $this->Paginator->last(2, array('tag' => 'li'));
|
||||||
$expected = '...<li><a href="/index/page:14">14</a></li> | <li><a href="/index/page:15">15</a></li>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'...',
|
||||||
|
'<li',
|
||||||
|
array('a' => array('href' => '/index/page:14')), '14', '/a',
|
||||||
|
'/li',
|
||||||
|
' | ',
|
||||||
|
'<li',
|
||||||
|
array('a' => array('href' => '/index/page:15')), '15', '/a',
|
||||||
|
'/li',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging'] = array('Client' => array(
|
$this->Paginator->params['paging'] = array('Client' => array(
|
||||||
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||||
|
@ -789,20 +1034,42 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->Paginator->first();
|
$result = $this->Paginator->first();
|
||||||
$expected = '<span><a href="/index/page:1/sort:Client.name/direction:DESC"><< first</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '<< first', '/a',
|
||||||
|
'/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last();
|
$result = $this->Paginator->last();
|
||||||
$expected = '<span><a href="/index/page:15/sort:Client.name/direction:DESC">last >></a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), 'last >>', '/a',
|
||||||
|
'/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last(1);
|
$result = $this->Paginator->last(1);
|
||||||
$expected = '...<span><a href="/index/page:15/sort:Client.name/direction:DESC">15</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'...',
|
||||||
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a',
|
||||||
|
'/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->last(2);
|
$result = $this->Paginator->last(2);
|
||||||
$expected = '...<span><a href="/index/page:14/sort:Client.name/direction:DESC">14</a></span> | <span><a href="/index/page:15/sort:Client.name/direction:DESC">15</a></span>';
|
$expected = array(
|
||||||
$this->assertEqual($result, $expected);
|
'...',
|
||||||
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:14/sort:Client.name/direction:DESC')), '14', '/a',
|
||||||
|
'/span',
|
||||||
|
' | ',
|
||||||
|
'<span',
|
||||||
|
array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a',
|
||||||
|
'/span',
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testCounter method
|
* testCounter method
|
||||||
|
@ -855,7 +1122,6 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$result = $this->Paginator->counter(array('format' => 'range'));
|
$result = $this->Paginator->counter(array('format' => 'range'));
|
||||||
$expected = '1 - 3 of 13';
|
$expected = '1 - 3 of 13';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testHasPage method
|
* testHasPage method
|
||||||
|
@ -893,23 +1159,37 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
|
|
||||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||||
$this->assertPattern('/["\']\/my_plugin\/magazines\/index\/page:3["\']/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/my_plugin/magazines/index/page:3'), 'Page 3', '/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->options(array('url' => array('action' => 'another_index')));
|
$this->Paginator->options(array('url' => array('action' => 'another_index')));
|
||||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||||
$this->assertPattern('/["\']\/my_plugin\/magazines\/another_index\/page:3["\']/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/my_plugin/magazines/another_index/page:3'), 'Page 3', '/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->options(array('url' => array('controller' => 'issues')));
|
$this->Paginator->options(array('url' => array('controller' => 'issues')));
|
||||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||||
$this->assertPattern('/["\']\/my_plugin\/issues\/index\/page:3["\']/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/my_plugin/issues/index/page:3'), 'Page 3', '/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->options(array('url' => array('plugin' => null)));
|
$this->Paginator->options(array('url' => array('plugin' => null)));
|
||||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||||
$this->assertPattern('/["\']\/magazines\/index\/page:3["\']/', $result);
|
$expected = array(
|
||||||
|
'a' => array('/magazines/index/page:3'), 'Page 3', '/a'
|
||||||
|
);
|
||||||
|
|
||||||
$this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
|
$this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
|
||||||
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
$result = $this->Paginator->link('Page 3', array('page' => 3));
|
||||||
$this->assertPattern('/["\']\/issues\/index\/page:3["\']/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/issues/index/page:3'), 'Page 3', '/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -937,7 +1217,12 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->Paginator->options($test);
|
$this->Paginator->options($test);
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$this->assertPattern('/\/accounts\/index\/page:2\/sort:Article.title\/direction:asc">Next<\/a>$/', $result);
|
$expected = array(
|
||||||
|
'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc'),
|
||||||
|
'Next',
|
||||||
|
'/a'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -27,6 +27,26 @@
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
if (!class_exists('AppError')) {
|
||||||
|
App::import('Error');
|
||||||
|
/**
|
||||||
|
* AppController class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.libs
|
||||||
|
*/
|
||||||
|
class AppError extends ErrorHandler {
|
||||||
|
/**
|
||||||
|
* _stop method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _stop() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
App::import('Core', array('Helper', 'AppHelper', 'Controller', 'View'));
|
App::import('Core', array('Helper', 'AppHelper', 'Controller', 'View'));
|
||||||
App::import('Helper', array('Session'));
|
App::import('Helper', array('Session'));
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +163,9 @@ class SessionHelperTest extends CakeTestCase {
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$_viewPaths = Configure::read('viewPaths');
|
||||||
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
||||||
|
|
||||||
$controller = new Controller();
|
$controller = new Controller();
|
||||||
$this->Session->view = new View($controller);
|
$this->Session->view = new View($controller);
|
||||||
|
|
||||||
|
@ -165,6 +187,36 @@ class SessionHelperTest extends CakeTestCase {
|
||||||
$expected = 'Bare message';
|
$expected = 'Bare message';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
$this->assertFalse($this->Session->check('Message.bare'));
|
$this->assertFalse($this->Session->check('Message.bare'));
|
||||||
|
|
||||||
|
Configure::write('viewPaths', $_viewPaths);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* testFlash method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testFlashMissingLayout() {
|
||||||
|
$_SESSION = array(
|
||||||
|
'Message' => array(
|
||||||
|
'notification' => array(
|
||||||
|
'layout' => 'does_not_exist',
|
||||||
|
'params' => array('title' => 'Notice!', 'name' => 'Alert!'),
|
||||||
|
'message' => 'This is a test of the emergency broadcasting system',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$controller = new Controller();
|
||||||
|
$this->Session->view = new View($controller);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$this->Session->flash('notification');
|
||||||
|
$result = ob_get_contents();
|
||||||
|
ob_clean();
|
||||||
|
|
||||||
|
$this->assertPattern("/Missing Layout/", $result);
|
||||||
|
$this->assertPattern("/layouts\/does_not_exist.ctp/", $result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testID method
|
* testID method
|
||||||
|
|
Loading…
Reference in a new issue