Added Classmap::addClassmap() method

This commit is contained in:
Francis Besset 2011-10-09 22:12:54 +02:00
parent 15123e9719
commit fffc5f71da
2 changed files with 21 additions and 0 deletions

View File

@ -83,4 +83,11 @@ class Classmap
{
return isset($this->classmap[$type]);
}
public function addClassmap(Classmap $classmap)
{
foreach ($classmap->all() as $type => $classname) {
$this->add($type, $classname);
}
}
}

View File

@ -64,4 +64,18 @@ class ClassmapTest extends \PHPUnit_Framework_TestCase
$this->assertSame($map, $classmap->all());
}
public function testAddClassmap()
{
$classmap1 = new Classmap();
$classmap2 = new Classmap();
$classmap2->add('foobar', 'BeSimple\SoapCommon\Classmap');
$classmap1->addClassmap($classmap2);
$this->assertEquals(array('foobar' => 'BeSimple\SoapCommon\Classmap'), $classmap1->all());
$this->setExpectedException('InvalidArgumentException');
$classmap1->addClassmap($classmap2);
}
}