Add coverage

This commit is contained in:
Romain Neutron
2012-05-22 14:38:49 +02:00
parent a85e798419
commit 961383c902
2 changed files with 38 additions and 0 deletions

View File

@@ -37,6 +37,12 @@ class Factory
case Attribute::NAME_STORY: case Attribute::NAME_STORY:
return Story::loadFromString($serialized); return Story::loadFromString($serialized);
break; 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)); throw new \InvalidArgumentException(sprintf('Unknown attribute %s', $name));

View File

@@ -41,6 +41,38 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Attribute\\Story', $attribute); $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 * @covers Alchemy\Phrasea\Border\Attribute\Factory::getFileAttribute
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException