Ejemplo n.º 1
0
 function testOrdering()
 {
     $map = new CallMap();
     $map->addValue(array(1, 2), "1, 2");
     $map->addValue(array(1, 3), "1, 3");
     $map->addValue(array(1), "1");
     $map->addValue(array(1, 4), "1, 4");
     $map->addValue(array(new AnythingExpectation()), "Any");
     $map->addValue(array(2), "2");
     $map->addValue("", "Default");
     $map->addValue(array(), "None");
     $this->assertEqual($map->findFirstMatch(array(1, 2)), "1, 2");
     $this->assertEqual($map->findFirstMatch(array(1, 3)), "1, 3");
     $this->assertEqual($map->findFirstMatch(array(1, 4)), "1, 4");
     $this->assertEqual($map->findFirstMatch(array(1)), "1");
     $this->assertEqual($map->findFirstMatch(array(2)), "Any");
     $this->assertEqual($map->findFirstMatch(array(3)), "Any");
     $this->assertEqual($map->findFirstMatch(array()), "Default");
 }
Ejemplo n.º 2
0
 function testOrdering()
 {
     $map = new CallMap("wild");
     $map->addValue("aMethod", array(1, 2), "1, 2");
     $map->addValue("aMethod", array(1, 3), "1, 3");
     $map->addValue("aMethod", array(1), "1");
     $map->addValue("aMethod", array(1, 4), "1, 4");
     $map->addValue("aMethod", array("wild"), "Any");
     $map->addValue("aMethod", array(2), "2");
     $map->addValue("aMethod", "", "Default");
     $map->addValue("aMethod", array(), "None");
     $this->assertEqual($map->findFirstMatch("aMethod", array(1, 2)), "1, 2");
     $this->assertEqual($map->findFirstMatch("aMethod", array(1, 3)), "1, 3");
     $this->assertEqual($map->findFirstMatch("aMethod", array(1, 4)), "1, 4");
     $this->assertEqual($map->findFirstMatch("aMethod", array(1)), "1");
     $this->assertEqual($map->findFirstMatch("aMethod", array(2)), "Any");
     $this->assertEqual($map->findFirstMatch("aMethod", array(3)), "Any");
     $this->assertEqual($map->findFirstMatch("aMethod", array()), "Default");
 }