From 1a6a5f2d268ecaacd662d04b41b4682eef99b002 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 7 Oct 2012 21:46:07 -0400 Subject: [PATCH] Fix more failing tests. --- .../Console/ConsoleErrorHandlerTest.php | 8 ++--- .../Component/AuthComponentTest.php | 2 +- .../Test/TestCase/Controller/ScaffoldTest.php | 2 +- lib/Cake/Test/TestCase/Utility/NumberTest.php | 4 +-- .../TestCase/View/Helper/FormHelperTest.php | 18 ++++------ .../TestCase/View/Helper/HtmlHelperTest.php | 2 +- lib/Cake/Test/TestCase/View/JsonViewTest.php | 34 ++++++++----------- lib/Cake/View/Helper/PaginatorHelper.php | 9 ++--- 8 files changed, 29 insertions(+), 50 deletions(-) diff --git a/lib/Cake/Test/TestCase/Console/ConsoleErrorHandlerTest.php b/lib/Cake/Test/TestCase/Console/ConsoleErrorHandlerTest.php index 6a1c9ad5734..6e24586483c 100644 --- a/lib/Cake/Test/TestCase/Console/ConsoleErrorHandlerTest.php +++ b/lib/Cake/Test/TestCase/Console/ConsoleErrorHandlerTest.php @@ -31,8 +31,8 @@ class ConsoleErrorHandlerTest extends TestCase { */ public function setUp() { parent::setUp(); - $this->Error = $this->getMock('Cake\Console\ConsoleErrorHandler', array('_stop')); - ConsoleErrorHandler::$stderr = $this->getMock('Cake\Console\ConsoleOutput', array(), array(), '', false); + $this->Error = $this->getMock('Cake\Console\ConsoleErrorHandler', ['_stop']); + ConsoleErrorHandler::$stderr = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false); } /** @@ -68,10 +68,6 @@ public function testHandleFatalError() { ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($content); - $this->Error->expects($this->once()) - ->method('_stop') - ->with(1); - $this->Error->handleError(E_USER_ERROR, 'This is a fatal error', '/some/file', 275); } diff --git a/lib/Cake/Test/TestCase/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/TestCase/Controller/Component/AuthComponentTest.php index b9cd92f008d..887345914ea 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/AuthComponentTest.php @@ -668,7 +668,7 @@ public function testDefaultToLoginRedirect() { /** * Throw ForbiddenException if AuthComponent::$unauthorizedRedirect set to false - * @expectedException ForbiddenException + * @expectedException Cake\Error\ForbiddenException * @return void */ public function testForbiddenException() { diff --git a/lib/Cake/Test/TestCase/Controller/ScaffoldTest.php b/lib/Cake/Test/TestCase/Controller/ScaffoldTest.php index 55b9c695a3a..48da4fa2381 100644 --- a/lib/Cake/Test/TestCase/Controller/ScaffoldTest.php +++ b/lib/Cake/Test/TestCase/Controller/ScaffoldTest.php @@ -297,7 +297,7 @@ public function testHabtmFieldAdditionWithScaffoldForm() { $Scaffold = new Scaffold($this->Controller, $this->Controller->request); $this->Controller->response->send(); $result = ob_get_clean(); - $this->assertRegExp('/name="data\[ScaffoldTag\]\[ScaffoldTag\]"/', $result); + $this->assertContains('name="ScaffoldTag[ScaffoldTag]"', $result); $result = $Scaffold->controller->viewVars; $this->assertEquals(array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated', 'ScaffoldTag'), $result['scaffoldFields']); diff --git a/lib/Cake/Test/TestCase/Utility/NumberTest.php b/lib/Cake/Test/TestCase/Utility/NumberTest.php index a11b5c8bf9e..6e58c28c9f5 100644 --- a/lib/Cake/Test/TestCase/Utility/NumberTest.php +++ b/lib/Cake/Test/TestCase/Utility/NumberTest.php @@ -79,7 +79,7 @@ public function testFormat() { $value = -0.00001; $result = $this->Number->format($value, array('places' => 1)); - $expected = '$0.0'; + $expected = '$-0.0'; $this->assertEquals($expected, $result); } @@ -588,7 +588,7 @@ public function testFromReadableSize($params, $expected) { /** * testFromReadableSize * - * @expectedException CakeException + * @expectedException Cake\Error\Exception * @return void */ public function testFromReadableSizeException() { diff --git a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php index a88dccf8074..a879504e6a0 100644 --- a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php @@ -1,9 +1,5 @@ * Copyright 2005-2012, Cake Software Foundation, Inc. * @@ -12,7 +8,6 @@ * * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests - * @package Cake.Test.Case.View.Helper * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -36,8 +31,7 @@ /** * ContactTestController class * - * @package cake - * @package Cake.Test.Case.View.Helper + * @package Cake.Test.Case.View.Helper */ class ContactTestController extends Controller { @@ -3524,11 +3518,11 @@ public function testRadioOptionWithZeroValue() { 'legend' => array(), 'Field', '/legend', - array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')), + array('input' => array('type' => 'radio', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField1')), array('label' => array('for' => 'ModelField1')), 'Yes', '/label', - array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0', 'checked' => 'checked')), + array('input' => array('type' => 'radio', 'name' => 'Model[field]', 'value' => '0', 'id' => 'ModelField0', 'checked' => 'checked')), array('label' => array('for' => 'ModelField0')), 'No', '/label', @@ -3545,12 +3539,12 @@ public function testRadioOptionWithZeroValue() { 'legend' => array(), 'Field', '/legend', - 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField_'), - array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')), + 'input' => array('type' => 'hidden', 'name' => 'Model[field]', 'value' => '', 'id' => 'ModelField_'), + array('input' => array('type' => 'radio', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField1')), array('label' => array('for' => 'ModelField1')), 'Yes', '/label', - array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0')), + array('input' => array('type' => 'radio', 'name' => 'Model[field]', 'value' => '0', 'id' => 'ModelField0')), array('label' => array('for' => 'ModelField0')), 'No', '/label', diff --git a/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php index b44ea12763f..143a9568515 100644 --- a/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php @@ -396,7 +396,7 @@ public function testImageWithFullBase() { $request = $this->Html->request; $request->webroot = '/myproject/'; $request->base = '/myproject'; - Router::setRequestInfo($request); + Router::pushRequest($request); $result = $this->Html->image('sub/test.gif', array('fullBase' => true)); $here = $this->Html->url('/', true); diff --git a/lib/Cake/Test/TestCase/View/JsonViewTest.php b/lib/Cake/Test/TestCase/View/JsonViewTest.php index b453fdcb1a0..e610eefab33 100644 --- a/lib/Cake/Test/TestCase/View/JsonViewTest.php +++ b/lib/Cake/Test/TestCase/View/JsonViewTest.php @@ -1,9 +1,5 @@ * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * @@ -12,7 +8,6 @@ * * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests - * @package Cake.Test.Case.View * @since CakePHP(tm) v 2.1.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,7 +22,7 @@ /** * JsonViewTest * - * @package Cake.Test.Case.View + * @package Cake.Test.Case.View */ class JsonViewTest extends TestCase { @@ -74,30 +69,29 @@ public function testRenderWithoutViewMultiple() { * @return void */ public function testRenderWithView() { - App::build(array( - 'View' => array(CAKE . 'Test/TestApp/View/') - )); + App::build([ + 'View' => [CAKE . 'Test/TestApp/View/'] + ]); $Request = new Request(); - $Request->params['named'] = array('page' => 2); $Response = new Response(); $Controller = new Controller($Request, $Response); $Controller->name = $Controller->viewPath = 'Posts'; - $data = array( - 'User' => array( + $data = [ + 'User' => [ 'username' => 'fake' - ), - 'Item' => array( - array('name' => 'item1'), - array('name' => 'item2') - ) - ); + ], + 'Item' => [ + ['name' => 'item1'], + ['name' => 'item2'] + ] + ]; $Controller->set('user', $data); $View = new JsonView($Controller); - $View->helpers = array('Paginator'); + $View->helpers = ['Paginator']; $output = $View->render('index'); - $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2'), 'paging' => array('page' => 2))); + $expected = json_encode(['user' => 'fake', 'list' => ['item1', 'item2'], 'paging' => []]); $this->assertSame($expected, $output); $this->assertSame('application/json', $Response->type()); } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index f9b94015db7..e86ef487a3a 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -1,9 +1,5 @@