From fffc5f71da093963a2526231a5caa48551ee027f Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 9 Oct 2011 22:12:54 +0200 Subject: [PATCH] Added Classmap::addClassmap() method --- src/BeSimple/SoapCommon/Classmap.php | 7 +++++++ tests/BeSimple/Tests/SoapCommon/ClassmapTest.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/BeSimple/SoapCommon/Classmap.php b/src/BeSimple/SoapCommon/Classmap.php index 3f0ece6..6f5fc4c 100644 --- a/src/BeSimple/SoapCommon/Classmap.php +++ b/src/BeSimple/SoapCommon/Classmap.php @@ -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); + } + } } \ No newline at end of file diff --git a/tests/BeSimple/Tests/SoapCommon/ClassmapTest.php b/tests/BeSimple/Tests/SoapCommon/ClassmapTest.php index 55f5998..a4a97de 100644 --- a/tests/BeSimple/Tests/SoapCommon/ClassmapTest.php +++ b/tests/BeSimple/Tests/SoapCommon/ClassmapTest.php @@ -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); + } } \ No newline at end of file