Browse Source

Removing Object::dispatchMethod, previously used by collections.

Renan Gonçalves 12 years ago
parent
commit
1a004f912f
2 changed files with 0 additions and 95 deletions
  1. 0 29
      src/Core/Object.php
  2. 0 66
      tests/TestCase/Core/ObjectTest.php

+ 0 - 29
src/Core/Object.php

@@ -46,35 +46,6 @@ class Object {
 	}
 
 /**
- * Calls a method on this object with the given parameters. Provides an OO wrapper
- * for `call_user_func_array`
- *
- * @param string $method Name of the method to call
- * @param array $params Parameter list to use when calling $method
- * @return mixed Returns the result of the method call
- */
-	public function dispatchMethod($method, array $params = []) {
-		switch (count($params)) {
-			case 0:
-				return $this->{$method}();
-			case 1:
-				return $this->{$method}($params[0]);
-			case 2:
-				return $this->{$method}($params[0], $params[1]);
-			case 3:
-				return $this->{$method}($params[0], $params[1], $params[2]);
-			case 4:
-				return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
-			case 5:
-				return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
-			default:
-				// @codingStandardsIgnoreStart
-				return call_user_func_array([&$this, $method], $params);
-				// @codingStandardsIgnoreEnd
-		}
-	}
-
-/**
  * Stop execution of the current script. Wraps exit() making
  * testing easier.
  *

+ 0 - 66
tests/TestCase/Core/ObjectTest.php

@@ -258,70 +258,4 @@ class ObjectTest extends TestCase {
 		$this->assertEquals(strtolower(__NAMESPACE__) . '\testobject', $result);
 	}
 
-/**
- * testMethodDispatching method
- *
- * @return void
- */
-	public function testMethodDispatching() {
-		$this->object->emptyMethod();
-		$expected = array('emptyMethod');
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->oneParamMethod('Hello');
-		$expected[] = array('oneParamMethod' => array('Hello'));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->twoParamMethod(true, false);
-		$expected[] = array('twoParamMethod' => array(true, false));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->threeParamMethod(true, false, null);
-		$expected[] = array('threeParamMethod' => array(true, false, null));
-		$this->assertSame($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->assertSame($this->object->methodCalls, $expected);
-
-		$this->object = new TestObject();
-		$this->assertSame($this->object->methodCalls, array());
-
-		$this->object->dispatchMethod('emptyMethod');
-		$expected = array('emptyMethod');
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('oneParamMethod', array('Hello'));
-		$expected[] = array('oneParamMethod' => array('Hello'));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('twoParamMethod', array(true, false));
-		$expected[] = array('twoParamMethod' => array(true, false));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('threeParamMethod', array(true, false, null));
-		$expected[] = array('threeParamMethod' => array(true, false, null));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('fourParamMethod', array(1, 2, 3, 4));
-		$expected[] = array('fourParamMethod' => array(1, 2, 3, 4));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('fiveParamMethod', array(1, 2, 3, 4, 5));
-		$expected[] = array('fiveParamMethod' => array(1, 2, 3, 4, 5));
-		$this->assertSame($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->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('methodWithOptionalParam', array('Hello'));
-		$expected[] = array('methodWithOptionalParam' => array("Hello"));
-		$this->assertSame($this->object->methodCalls, $expected);
-
-		$this->object->dispatchMethod('methodWithOptionalParam');
-		$expected[] = array('methodWithOptionalParam' => array(null));
-		$this->assertSame($this->object->methodCalls, $expected);
-	}
-
 }