mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
5e8a2fb7f4
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6459 3807eeeb-6ff5-0310-8944-8be069107fe0
131 lines
No EOL
4.3 KiB
PHP
131 lines
No EOL
4.3 KiB
PHP
<?php
|
|
/* SVN FILE: $Id$ */
|
|
/**
|
|
* Short description for file.
|
|
*
|
|
* Long description for file
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
* Las Vegas, Nevada 89104
|
|
*
|
|
* Licensed under The Open Group Test Suite License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @filesource
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
* @package cake.tests
|
|
* @subpackage cake.tests.cases.libs
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
|
* @version $Revision$
|
|
* @modifiedby $LastChangedBy$
|
|
* @lastmodified $Date$
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
*/
|
|
App::import('Core', 'Object');
|
|
|
|
class TestObject extends Object {
|
|
|
|
var $methodCalls = array();
|
|
|
|
function emptyMethod() {
|
|
$this->methodCalls[] = 'emptyMethod';
|
|
}
|
|
|
|
function oneParamMethod($param) {
|
|
$this->methodCalls[] = array('oneParamMethod' => array($param));
|
|
}
|
|
|
|
function twoParamMethod($param, $param2) {
|
|
$this->methodCalls[] = array('twoParamMethod' => array($param, $param2));
|
|
}
|
|
|
|
function threeParamMethod($param, $param2, $param3) {
|
|
$this->methodCalls[] = array('threeParamMethod' => array($param, $param2, $param3));
|
|
}
|
|
|
|
function crazyMethod($param, $param2, $param3, $param4, $param5, $param6, $param7 = null) {
|
|
$this->methodCalls[] = array('crazyMethod' => array($param, $param2, $param3, $param4, $param5, $param6, $param7));
|
|
}
|
|
|
|
function methodWithOptionalParam($param = null) {
|
|
$this->methodCalls[] = array('methodWithOptionalParam' => array($param));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Short description for class.
|
|
*
|
|
* @package cake.tests
|
|
* @subpackage cake.tests.cases.libs
|
|
*/
|
|
class ObjectTest extends UnitTestCase {
|
|
|
|
function setUp() {
|
|
$this->object = new TestObject();
|
|
}
|
|
|
|
function testToString() {
|
|
$result = strtolower($this->object->toString());
|
|
$this->assertEqual($result, 'testobject');
|
|
}
|
|
|
|
function testMethodDispatching() {
|
|
$this->object->emptyMethod();
|
|
$expected = array('emptyMethod');
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->oneParamMethod('Hello');
|
|
$expected[] = array('oneParamMethod' => array('Hello'));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->twoParamMethod(true, false);
|
|
$expected[] = array('twoParamMethod' => array(true, false));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->threeParamMethod(true, false, null);
|
|
$expected[] = array('threeParamMethod' => array(true, false, null));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->crazyMethod(1, 2, 3, 4, 5, 6, 7);
|
|
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object = new TestObject();
|
|
$this->assertIdentical($this->object->methodCalls, array());
|
|
|
|
$this->object->dispatchMethod('emptyMethod');
|
|
$expected = array('emptyMethod');
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->dispatchMethod('oneParamMethod', array('Hello'));
|
|
$expected[] = array('oneParamMethod' => array('Hello'));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->dispatchMethod('threeParamMethod', array(true, false, null));
|
|
$expected[] = array('threeParamMethod' => array(true, false, null));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->dispatchMethod('crazyMethod', array(1, 2, 3, 4, 5, 6, 7));
|
|
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->dispatchMethod('methodWithOptionalParam', array('Hello'));
|
|
$expected[] = array('methodWithOptionalParam' => array("Hello"));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
$this->object->dispatchMethod('methodWithOptionalParam');
|
|
$expected[] = array('methodWithOptionalParam' => array(null));
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
}
|
|
|
|
function tearDown() {
|
|
unset($this->object);
|
|
}
|
|
}
|
|
|
|
?>
|