cakephp2-php8/lib/Cake/Test/Case/View/Helper/NumberHelperTest.php

86 lines
1.9 KiB
PHP
Raw Normal View History

2012-02-06 10:12:01 +00:00
<?php
/**
* NumberHelperTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing 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)
*/
App::uses('View', 'View');
App::uses('NumberHelper', 'View/Helper');
/**
* NumberHelperTestObject class
*/
class NumberHelperTestObject extends NumberHelper {
public function attach(CakeNumberMock $cakeNumber) {
2012-02-06 10:12:01 +00:00
$this->_CakeNumber = $cakeNumber;
}
}
/**
* CakeNumberMock class
*/
class CakeNumberMock {
}
2012-02-06 10:12:01 +00:00
/**
* NumberHelperTest class
*
* @package Cake.Test.Case.View.Helper
*/
class NumberHelperTest extends CakeTestCase {
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->View = new View(null);
2012-02-06 10:12:01 +00:00
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
parent::tearDown();
unset($this->View);
2012-02-06 10:12:01 +00:00
}
/**
* test CakeNumber class methods are called correctly
*/
public function testNumberHelperProxyMethodCalls() {
$methods = array(
'precision', 'toReadableSize', 'toPercentage', 'format',
'currency', 'addFormat',
);
$CakeNumber = $this->getMock('CakeNumberMock', $methods);
$Number = new NumberHelperTestObject($this->View, array('engine' => 'CakeNumberMock'));
$Number->attach($CakeNumber);
2012-02-06 10:12:01 +00:00
foreach ($methods as $method) {
$CakeNumber->expects($this->at(0))->method($method);
$Number->{$method}('who', 'what', 'when', 'where', 'how');
2012-02-06 10:12:01 +00:00
}
}
}