From 961383c902d94c8a465173657c9798965db34cfd Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 22 May 2012 14:38:49 +0200 Subject: [PATCH] Add coverage --- .../Phrasea/Border/Attribute/Factory.php | 6 ++++ .../Phrasea/Border/Attribute/FactoryTest.php | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/Alchemy/Phrasea/Border/Attribute/Factory.php b/lib/Alchemy/Phrasea/Border/Attribute/Factory.php index 76939a4fc0..d6e95a4862 100644 --- a/lib/Alchemy/Phrasea/Border/Attribute/Factory.php +++ b/lib/Alchemy/Phrasea/Border/Attribute/Factory.php @@ -37,6 +37,12 @@ class Factory case Attribute::NAME_STORY: return Story::loadFromString($serialized); break; + case Attribute::NAME_METAFIELD: + return MetaField::loadFromString($serialized); + break; + case Attribute::NAME_STATUS: + return Status::loadFromString($serialized); + break; } throw new \InvalidArgumentException(sprintf('Unknown attribute %s', $name)); diff --git a/tests/Alchemy/Phrasea/Border/Attribute/FactoryTest.php b/tests/Alchemy/Phrasea/Border/Attribute/FactoryTest.php index ff622d2ba1..ce9ef5b15a 100644 --- a/tests/Alchemy/Phrasea/Border/Attribute/FactoryTest.php +++ b/tests/Alchemy/Phrasea/Border/Attribute/FactoryTest.php @@ -41,6 +41,38 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Story', $attribute); } + /** + * @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute + */ + public function testGetFileAttributeMetaField() + { + $databox_field = null; + foreach (self::$collection->get_databox()->get_meta_structure() as $df) { + $databox_field = $df; + break; + } + + if ( ! $databox_field) { + $this->markTestSkipped('No databox field found'); + } + + $metafield = new MetaField($databox_field, 'value'); + + $attribute = Factory::getFileAttribute(Attribute::NAME_METAFIELD, $metafield->asString()); + + $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\MetaField', $attribute); + } + + /** + * @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute + */ + public function testGetFileAttributeStatus() + { + $attribute = Factory::getFileAttribute(Attribute::NAME_STATUS, '000100'); + + $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Status', $attribute); + } + /** * @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute * @expectedException \InvalidArgumentException