From 69d1e59edfe240b8e1ddb4380c25c19fbb73b9eb Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 10 Sep 2011 19:14:38 +0200 Subject: [PATCH] Added TypeConverterCollection --- .../Converter/TypeConverterCollection.php | 31 ++++++++++++++ .../Converter/TypeConverterInterface.php | 27 +++++++++++++ .../Converter/TypeConverterCollectionTest.php | 40 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/BeSimple/SoapCommon/Converter/TypeConverterCollection.php create mode 100644 src/BeSimple/SoapCommon/Converter/TypeConverterInterface.php create mode 100644 tests/BeSimple/Tests/SoapCommon/Converter/TypeConverterCollectionTest.php diff --git a/src/BeSimple/SoapCommon/Converter/TypeConverterCollection.php b/src/BeSimple/SoapCommon/Converter/TypeConverterCollection.php new file mode 100644 index 0000000..fbdd79b --- /dev/null +++ b/src/BeSimple/SoapCommon/Converter/TypeConverterCollection.php @@ -0,0 +1,31 @@ + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapCommon\Converter; + +/** + * @author Christian Kerl + */ +class TypeConverterCollection +{ + private $typeConverters = array(); + + public function add(TypeConverterInterface $converter) + { + $this->typeConverters[] = $converter; + } + + public function all() + { + return $this->typeConverters; + } +} diff --git a/src/BeSimple/SoapCommon/Converter/TypeConverterInterface.php b/src/BeSimple/SoapCommon/Converter/TypeConverterInterface.php new file mode 100644 index 0000000..4de7d7f --- /dev/null +++ b/src/BeSimple/SoapCommon/Converter/TypeConverterInterface.php @@ -0,0 +1,27 @@ + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapCommon\Converter; + +/** + * @author Christian Kerl + */ +interface TypeConverterInterface +{ + function getTypeNamespace(); + + function getTypeName(); + + function convertXmlToPhp($data); + + function convertPhpToXml($data); +} \ No newline at end of file diff --git a/tests/BeSimple/Tests/SoapCommon/Converter/TypeConverterCollectionTest.php b/tests/BeSimple/Tests/SoapCommon/Converter/TypeConverterCollectionTest.php new file mode 100644 index 0000000..4c9feef --- /dev/null +++ b/tests/BeSimple/Tests/SoapCommon/Converter/TypeConverterCollectionTest.php @@ -0,0 +1,40 @@ + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapCommon\Tests\Converter; + +use BeSimple\SoapCommon\Converter\TypeConverterCollection; +use BeSimple\SoapCommon\Converter\DateTimeTypeConverter; +use BeSimple\SoapCommon\Converter\DateTypeConverter; + +/** + * UnitTest for \BeSimple\SoapCommon\Converter\TypeConverterCollection. + * + * @author Francis Besset + */ +class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase +{ + public function testAdd() + { + $converters = new TypeConverterCollection(); + + $dateTimeTypeConverter = new DateTimeTypeConverter(); + $converters->add($dateTimeTypeConverter); + + $this->assertSame(array($dateTimeTypeConverter), $converters->all()); + + $dateTypeConverter = new DateTypeConverter(); + $converters->add($dateTypeConverter); + + $this->assertSame(array($dateTimeTypeConverter, $dateTypeConverter), $converters->all()); + } +} \ No newline at end of file