Skip to content

Commit

Permalink
Fix more failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 8, 2012
1 parent 2f2237b commit 1a6a5f2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 50 deletions.
8 changes: 2 additions & 6 deletions lib/Cake/Test/TestCase/Console/ConsoleErrorHandlerTest.php
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Controller/ScaffoldTest.php
Expand Up @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/TestCase/Utility/NumberTest.php
Expand Up @@ -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);
}

Expand Down Expand Up @@ -588,7 +588,7 @@ public function testFromReadableSize($params, $expected) {
/**
* testFromReadableSize
*
* @expectedException CakeException
* @expectedException Cake\Error\Exception
* @return void
*/
public function testFromReadableSizeException() {
Expand Down
18 changes: 6 additions & 12 deletions lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php
@@ -1,9 +1,5 @@
<?php
/**
* FormHelperTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc.
*
Expand All @@ -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)
*/
Expand All @@ -36,8 +31,7 @@
/**
* ContactTestController class
*
* @package cake
* @package Cake.Test.Case.View.Helper
* @package Cake.Test.Case.View.Helper
*/
class ContactTestController extends Controller {

Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php
Expand Up @@ -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);
Expand Down
34 changes: 14 additions & 20 deletions lib/Cake/Test/TestCase/View/JsonViewTest.php
@@ -1,9 +1,5 @@
<?php
/**
* JsonViewTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand All @@ -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)
*/
Expand All @@ -27,7 +22,7 @@
/**
* JsonViewTest
*
* @package Cake.Test.Case.View
* @package Cake.Test.Case.View
*/
class JsonViewTest extends TestCase {

Expand Down Expand Up @@ -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());
}
Expand Down
9 changes: 2 additions & 7 deletions lib/Cake/View/Helper/PaginatorHelper.php
@@ -1,9 +1,5 @@
<?php
/**
* Pagination Helper class file.
*
* Generates pagination links
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand All @@ -12,7 +8,6 @@
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.View.Helper
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
Expand All @@ -29,8 +24,8 @@
*
* PaginationHelper encloses all methods needed when working with pagination.
*
* @package Cake.View.Helper
* @property HtmlHelper $Html
* @package Cake.View.Helper
* @property HtmlHelper $Html
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html
*/
class PaginatorHelper extends Helper {
Expand Down

0 comments on commit 1a6a5f2

Please sign in to comment.