\n";
foreach ($otherFields as $_field) {
- echo "\t\t\t".${$otherSingularVar}[$_field]." | \n";
+ echo "\t\t\t" . ${$otherSingularVar}[$_field] . " | \n";
}
echo "\t\t\t\n";
diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php
index 2baede3a8..04900aa9f 100644
--- a/cake/tests/cases/console/cake.test.php
+++ b/cake/tests/cases/console/cake.test.php
@@ -36,6 +36,8 @@ if (!class_exists('ShellDispatcher')) {
ob_end_clean();
}
+
+require_once CONSOLE_LIBS . 'shell.php';
/**
* TestShellDispatcher class
*
@@ -76,6 +78,13 @@ class TestShellDispatcher extends ShellDispatcher {
*/
var $stopped = null;
+/**
+ * TestShell
+ *
+ * @var mixed
+ * @access public
+ */
+ var $TestShell;
/**
* _initEnvironment method
*
@@ -127,6 +136,30 @@ class TestShellDispatcher extends ShellDispatcher {
*/
function _stop($status = 0) {
$this->stopped = 'Stopped with status: ' . $status;
+ return $status;
+ }
+/**
+ * getShell
+ *
+ * @param mixed $plugin
+ * @access public
+ * @return mixed
+ */
+ function getShell($plugin = null) {
+ return $this->_getShell($plugin);
+ }
+/**
+ * _getShell
+ *
+ * @param mixed $plugin
+ * @access protected
+ * @return mixed
+ */
+ function _getShell($plugin = null) {
+ if (isset($this->TestShell)) {
+ return $this->TestShell;
+ }
+ return parent::_getShell($plugin);
}
}
@@ -136,7 +169,7 @@ class TestShellDispatcher extends ShellDispatcher {
* @package cake
* @subpackage cake.tests.cases.libs
*/
-class ShellDispatcherTest extends UnitTestCase {
+class ShellDispatcherTest extends CakeTestCase {
/**
* setUp method
@@ -418,6 +451,25 @@ class ShellDispatcherTest extends UnitTestCase {
$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);
}
/**
@@ -444,20 +496,418 @@ class ShellDispatcherTest extends UnitTestCase {
}
/**
- * testDispatch method
+ * Verify loading of (plugin-) shells
*
* @access public
* @return void
*/
- function testDispatch() {
- $Dispatcher =& new TestShellDispatcher(array('sample'));
- $this->assertPattern('/This is the main method called from SampleShell/', $Dispatcher->stdout);
+ 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(array('test_plugin_two.example'));
- $this->assertPattern('/This is the main method called from TestPluginTwo.ExampleShell/', $Dispatcher->stdout);
+ $Dispatcher =& new TestShellDispatcher();
- $Dispatcher =& new TestShellDispatcher(array('test_plugin_two.welcome', 'say_hello'));
- $this->assertPattern('/This is the say_hello method called from TestPluginTwo.WelcomeShell/', $Dispatcher->stdout);
+ $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 correct dispatch of Shell subclasses with a main method
+ *
+ * @access public
+ * @return void
+ */
+ 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 without a main method
+ *
+ * @access public
+ * @return void
+ */
+ 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 custom classes with a main method
+ *
+ * @access public
+ * @return void
+ */
+ 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 without a main method
+ *
+ * @access public
+ * @return void
+ */
+ 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 that a task is called instead of the shell if the first arg equals
+ * the name of the task
+ *
+ * @access public
+ * @return void
+ */
+ 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 shifting of arguments
+ *
+ * @access public
+ * @return void
+ */
+ 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());
}
/**
@@ -502,7 +952,7 @@ class ShellDispatcherTest extends UnitTestCase {
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t sample";
$expected .= "\n/";
- $this->assertPattern($expected, $Dispatcher->stdout);
+ $this->assertPattern($expected, $Dispatcher->stdout);
}
}
?>
\ No newline at end of file
diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php
index 9672c9cd1..5acf7d6fa 100644
--- a/cake/tests/cases/console/libs/shell.test.php
+++ b/cake/tests/cases/console/libs/shell.test.php
@@ -52,6 +52,23 @@ Mock::generatePartial(
* @subpackage cake.tests.cases.console.libs
*/
class TestShell extends Shell {
+/**
+ * stopped property
+ *
+ * @var integer
+ * @access public
+ */
+ var $stopped;
+/**
+ * stop method
+ *
+ * @param integer $status
+ * @access protected
+ * @return void
+ */
+ function _stop($status = 0) {
+ $this->stopped = $status;
+ }
}
/**
@@ -157,20 +174,6 @@ class ShellTest extends CakeTestCase {
App::build();
}
-/**
- * testOut method
- *
- * @return void
- * @access public
- */
- function testOut() {
- $this->Shell->Dispatch->expectAt(0, 'stdout', array('Just a test', true));
- $this->Shell->out('Just a test');
-
- $this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", true));
- $this->Shell->out(array('Just', 'a', 'test'));
- }
-
/**
* testIn method
*
@@ -209,6 +212,94 @@ class ShellTest extends CakeTestCase {
$this->assertEqual($result, 'n');
}
+/**
+ * testOut method
+ *
+ * @return void
+ * @access public
+ */
+ function testOut() {
+ $this->Shell->Dispatch->expectAt(0, 'stdout', array("Just a test\n", false));
+ $this->Shell->out('Just a test');
+
+ $this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", false));
+ $this->Shell->out(array('Just', 'a', 'test'));
+
+ $this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false));
+ $this->Shell->out(array('Just', 'a', 'test'), 2);
+ }
+/**
+ * testErr method
+ *
+ * @return void
+ * @access public
+ */
+ function testErr() {
+ $this->Shell->Dispatch->expectAt(0, 'stderr', array("Just a test\n"));
+ $this->Shell->err('Just a test');
+
+ $this->Shell->Dispatch->expectAt(1, 'stderr', array("Just\na\ntest\n"));
+ $this->Shell->err(array('Just', 'a', 'test'));
+
+ $this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n"));
+ $this->Shell->err(array('Just', 'a', 'test'), 2);
+ }
+/**
+ * testNl
+ *
+ * @access public
+ * @return void
+ */
+ function testNl() {
+ $this->assertEqual($this->Shell->nl(), "\n");
+ $this->assertEqual($this->Shell->nl(true), "\n");
+ $this->assertEqual($this->Shell->nl(false), "");
+ $this->assertEqual($this->Shell->nl(2), "\n\n");
+ $this->assertEqual($this->Shell->nl(1), "\n");
+ $this->assertEqual($this->Shell->nl("custom"), "custom\n");
+ }
+/**
+ * testHr
+ *
+ * @access public
+ * @return void
+ */
+ function testHr() {
+ $bar = '---------------------------------------------------------------';
+
+ $this->Shell->Dispatch->expectAt(0, 'stdout', array('', false));
+ $this->Shell->Dispatch->expectAt(1, 'stdout', array($bar . "\n", false));
+ $this->Shell->Dispatch->expectAt(2, 'stdout', array('', false));
+ $this->Shell->hr();
+
+ $this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false));
+ $this->Shell->Dispatch->expectAt(4, 'stdout', array($bar . "\n", false));
+ $this->Shell->Dispatch->expectAt(5, 'stdout', array("\n", false));
+ $this->Shell->hr(true);
+
+ $this->Shell->Dispatch->expectAt(3, 'stdout', array("\n\n", false));
+ $this->Shell->Dispatch->expectAt(4, 'stdout', array($bar . "\n", false));
+ $this->Shell->Dispatch->expectAt(5, 'stdout', array("\n\n", false));
+ $this->Shell->hr(2);
+ }
+/**
+ * testError
+ *
+ * @access public
+ * @return void
+ */
+ function testError() {
+ $this->Shell->Dispatch->expectAt(0, 'stderr', array("Error: Foo Not Found\n"));
+ $this->Shell->error('Foo Not Found');
+ $this->assertIdentical($this->Shell->stopped, 1);
+
+ $this->Shell->stopped = null;
+
+ $this->Shell->Dispatch->expectAt(1, 'stderr', array("Error: Foo Not Found\n"));
+ $this->Shell->Dispatch->expectAt(2, 'stderr', array("Searched all...\n"));
+ $this->Shell->error('Foo Not Found', 'Searched all...');
+ $this->assertIdentical($this->Shell->stopped, 1);
+ }
/**
* testLoadTasks method
*
diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php
index 4dcaabb3c..6389823d4 100644
--- a/cake/tests/cases/libs/http_socket.test.php
+++ b/cake/tests/cases/libs/http_socket.test.php
@@ -539,12 +539,12 @@ class HttpSocketTest extends CakeTestCase {
$this->Socket->setReturnValue('read', false);
$this->Socket->_mock->_call_counts['read'] = 0;
$number = mt_rand(0, 9999999);
- $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nHello, your lucky number is ".$number."";
+ $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nHello, your lucky number is " . $number . "";
$this->Socket->setReturnValueAt(0, 'read', $serverResponse);
$this->Socket->expect('write', array("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"));
$this->Socket->expectCallCount('read', 2);
$response = $this->Socket->request($request);
- $this->assertIdentical($response, "Hello, your lucky number is ".$number."");
+ $this->assertIdentical($response, "Hello, your lucky number is " . $number . "");
$this->Socket->reset();
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nThis is a cookie test!";
diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php
index 54b6fa3c3..7780a4448 100644
--- a/cake/tests/cases/libs/router.test.php
+++ b/cake/tests/cases/libs/router.test.php
@@ -1705,5 +1705,74 @@ class RouterTest extends CakeTestCase {
$this->assertEqual(Router::stripPlugin($url), $url);
$this->assertEqual(Router::stripPlugin($url, null), $url);
}
+/**
+ * testCurentRoute
+ *
+ * This test needs some improvement and actual requestAction() usage
+ *
+ * @return void
+ * @access public
+ */
+ function testCurentRoute() {
+ $url = array('controller' => 'pages', 'action' => 'display', 'government');
+ Router::connect('/government', $url);
+ Router::parse('/government');
+ $route = Router::currentRoute();
+ $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
+ }
+/**
+ * testRequestRoute
+ *
+ * @return void
+ * @access public
+ */
+ function testRequestRoute() {
+ $url = array('controller' => 'products', 'action' => 'display', 5);
+ Router::connect('/government', $url);
+ Router::parse('/government');
+ $route = Router::requestRoute();
+ $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
+
+ // test that the first route is matched
+ $newUrl = array('controller' => 'products', 'action' => 'display', 6);
+ Router::connect('/government', $url);
+ Router::parse('/government');
+ $route = Router::requestRoute();
+ $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
+
+ // test that an unmatched route does not change the current route
+ $newUrl = array('controller' => 'products', 'action' => 'display', 6);
+ Router::connect('/actor', $url);
+ Router::parse('/government');
+ $route = Router::requestRoute();
+ $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
+ }
+/**
+ * testGetParams
+ *
+ * @return void
+ * @access public
+ */
+ function testGetParams() {
+ $paths = array('base' => '/', 'here' => '/products/display/5', 'webroot' => '/webroot');
+ $params = array('param1' => '1', 'param2' => '2');
+ Router::setRequestInfo(array($params, $paths));
+ $expected = array(
+ 'plugin' => false, 'controller' => false, 'action' => false,
+ 'param1' => '1', 'param2' => '2'
+ );
+ $this->assertEqual(Router::getparams(), $expected);
+ $this->assertEqual(Router::getparam('controller'), false);
+ $this->assertEqual(Router::getparam('param1'), '1');
+ $this->assertEqual(Router::getparam('param2'), '2');
+
+ Router::reload();
+
+ $params = array('controller' => 'pages', 'action' => 'display');
+ Router::setRequestInfo(array($params, $paths));
+ $expected = array('plugin' => false, 'controller' => 'pages', 'action' => 'display');
+ $this->assertEqual(Router::getparams(), $expected);
+ $this->assertEqual(Router::getparams(true), $expected);
+ }
}
?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php
index 16dc92e18..32d15a68e 100644
--- a/cake/tests/cases/libs/sanitize.test.php
+++ b/cake/tests/cases/libs/sanitize.test.php
@@ -311,8 +311,8 @@ class SanitizeTest extends CakeTestCase {
$result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected);
- $string = ''."\n".''."\n".''."\n".'';
- $expected = "\n".''."\n".''."\n".'';
+ $string = '' . "\n" . '' . "\n" . '' . "\n" . '';
+ $expected = "\n" . '' . "\n" . ''."\n".'';
$result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected);
diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php
index 7b7c93523..329328ae8 100644
--- a/cake/tests/cases/libs/view/helpers/paginator.test.php
+++ b/cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -765,29 +765,116 @@ class PaginatorHelperTest extends CakeTestCase {
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
);
$result = $this->Paginator->numbers();
- $expected = '4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '8', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('tag' => 'li'));
- $expected = '4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
+ ' | ',
+ array('li' => array('class' => 'current')), '8', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
+ );
+ $this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false));
- $expected = '456789101112';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
+ array('li' => array('class' => 'current')), '8', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
+ array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
+ );
+ $this->assertTags($result, $expected);
$result = $this->Paginator->numbers(true);
- $expected = 'first | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | last';
- $this->assertEqual($result, $expected);
-
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '8', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
+
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
);
$result = $this->Paginator->numbers();
- $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array('class' => 'current')), '1', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
+
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -795,8 +882,26 @@ class PaginatorHelperTest extends CakeTestCase {
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
);
$result = $this->Paginator->numbers();
- $expected = '7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '14', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9,
@@ -805,12 +910,48 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->numbers(array('first' => 1));
- $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '2', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('last' => 1));
- $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '2', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -819,8 +960,29 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->numbers(array('first' => 1));
- $expected = '1...7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '15', '/span',
+
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -829,8 +991,30 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
- $expected = '1...6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '10', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
@@ -839,8 +1023,30 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
- $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10...42';
- $this->assertEqual($result, $expected);
+ $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:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '6', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
@@ -849,8 +1055,30 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
- $expected = '1...33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:34')), '34', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:35')), '35', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:36')), '36', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '37', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:38')), '38', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:39')), '39', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:40')), '40', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:41')), '41', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array(
'Client' => array(
@@ -876,8 +1104,14 @@ class PaginatorHelperTest extends CakeTestCase {
);
$options = array('modulus' => 10);
$result = $this->Paginator->numbers($options);
- $expected = '1 | 2 | 3';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array('class' => 'current')), '1', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4,
@@ -885,8 +1119,17 @@ class PaginatorHelperTest extends CakeTestCase {
'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
);
$result = $this->Paginator->numbers();
- $expected = '1 | 2 | 3 | 4';
- $this->assertEqual($result, $expected);
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'current')), '2', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
+
$this->Paginator->params['paging'] = array('Client' => array(
'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
@@ -910,11 +1153,7 @@ class PaginatorHelperTest extends CakeTestCase {
);
$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()))
- );
+ $this->Paginator->params['paging']['Client']['page'] = 3;
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
$expected = array(
@@ -947,6 +1186,125 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
);
$this->assertTags($result, $expected);
+
+ $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, '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:5')), '5', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/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);
+
+ $this->Paginator->params['paging']['Client']['page'] = 4893;
+ $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, '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()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:4891')), '4891', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4892')), '4892', '/a', '/span',
+ ' - ',
+ array('span' => array('class' => 'current')), '4893', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/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);
+
+ $this->Paginator->params['paging']['Client']['page'] = 58;
+ $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, '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()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:56')), '56', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:57')), '57', '/a', '/span',
+ ' - ',
+ array('span' => array('class' => 'current')), '58', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:59')), '59', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:60')), '60', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/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);
+
+ $this->Paginator->params['paging']['Client']['page'] = 5;
+ $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, '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()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' - ',
+ array('span' => array('class' => 'current')), '5', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ '...',
+ array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
+ ' - ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/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);
}
/**
diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_reporter.php
index 18ab5f762..0dd954898 100644
--- a/cake/tests/lib/cake_reporter.php
+++ b/cake/tests/lib/cake_reporter.php
@@ -97,7 +97,6 @@ class CakeHtmlReporter extends SimpleReporter {
echo "" . $this->getFailCount() . " fails and ";
echo "" . $this->getExceptionCount() . " exceptions.";
echo "\n";
- echo " |