SimpleSignatureMap::add PHP Method

add() public method

Stashes a reference against a method call.
public add ( array $parameters, mixed $action )
$parameters array Array of arguments (including wildcards).
$action mixed Reference placed in the map.
    public function add($parameters, $action)
    {
        $place = count($this->map);
        $this->map[$place] = array();
        $this->map[$place]['params'] = new ParametersExpectation($parameters);
        $this->map[$place]['content'] = $action;
    }

Usage Example

コード例 #1
0
 function testOrdering()
 {
     $map = new SimpleSignatureMap();
     $map->add(array(1, 2), new SimpleByValue("1, 2"));
     $map->add(array(1, 3), new SimpleByValue("1, 3"));
     $map->add(array(1), new SimpleByValue("1"));
     $map->add(array(1, 4), new SimpleByValue("1, 4"));
     $map->add(array(new AnythingExpectation()), new SimpleByValue("Any"));
     $map->add(array(2), new SimpleByValue("2"));
     $map->add("", new SimpleByValue("Default"));
     $map->add(array(), new SimpleByValue("None"));
     $this->assertEqual($map->findFirstAction(array(1, 2)), new SimpleByValue("1, 2"));
     $this->assertEqual($map->findFirstAction(array(1, 3)), new SimpleByValue("1, 3"));
     $this->assertEqual($map->findFirstAction(array(1, 4)), new SimpleByValue("1, 4"));
     $this->assertEqual($map->findFirstAction(array(1)), new SimpleByValue("1"));
     $this->assertEqual($map->findFirstAction(array(2)), new SimpleByValue("Any"));
     $this->assertEqual($map->findFirstAction(array(3)), new SimpleByValue("Any"));
     $this->assertEqual($map->findFirstAction(array()), new SimpleByValue("Default"));
 }
All Usage Examples Of SimpleSignatureMap::add