/home/datas/noweb/db_alch_phrasea/subdefs/ yes image 1000 150 no 75 '; $type = new \Alchemy\Phrasea\Media\Type\Image(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertEquals(databox_subdef::CLASS_PREVIEW, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/subdefs/', $object->get_path()); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\Subdef\\Subdef', $object->getSubdefType()); $this->assertEquals($type, $object->getSubdefGroup()); $labels = $object->get_labels(); $this->assertTrue(is_array($labels)); $this->assertArrayHasKey('fr', $labels); $this->assertEquals('Prévisualisation', $labels['fr']); $this->assertArrayHasKey('en', $labels); $this->assertEquals('Preview', $labels['en']); $this->assertTrue($object->is_downloadable()); $this->assertTrue(is_array($object->getAvailableSubdefTypes())); $this->assertTrue(count($object->getAvailableSubdefTypes()) > 0); foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Image', $type); } $this->assertTrue($object->isMetadataUpdateRequired()); $this->assertEquals('preview_api', $object->get_name()); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Image', $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option); } } /** * @covers databox_subdef::__construct * @covers databox_subdef::get_class * @covers databox_subdef::get_name * @covers databox_subdef::isMetadataUpdateRequired * @covers databox_subdef::getAvailableSubdefTypes * @covers databox_subdef::is_downloadable * @covers databox_subdef::get_labels * @covers databox_subdef::getSubdefGroup * @covers databox_subdef::getSubdefType * @covers databox_subdef::get_path * @covers databox_subdef::getSpecs * @covers databox_subdef::getOptions * @covers databox_subdef::buildVideoSubdef */ public function testVideo() { $xml = ' /home/datas/noweb/db_alch_phrasea/video/ no video 196 72 yes 75 10 1 192 libfaac libx264 '; $type = new \Alchemy\Phrasea\Media\Type\Video(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertEquals(databox_subdef::CLASS_THUMBNAIL, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/video/', $object->get_path()); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\Subdef\\Subdef', $object->getSubdefType()); $this->assertEquals($type, $object->getSubdefGroup()); $labels = $object->get_labels(); $this->assertTrue(is_array($labels)); $this->assertEquals(0, count($labels)); $this->assertFalse($object->is_downloadable()); $this->assertTrue(is_array($object->getAvailableSubdefTypes())); $this->assertTrue(count($object->getAvailableSubdefTypes()) > 0); foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Subdef', $type); } $this->assertFalse($object->isMetadataUpdateRequired()); $this->assertEquals('video_api', $object->get_name()); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Video', $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option); } } /** * @covers databox_subdef::__construct * @covers databox_subdef::getSpecs * @covers databox_subdef::getOptions * @covers databox_subdef::buildGifSubdef */ public function testGif() { $xml = ' /home/datas/noweb/db_alch_phrasea/video/ no gif 200 yes 100 '; $type = new \Alchemy\Phrasea\Media\Type\Video(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Animation', $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option); } } /** * @covers databox_subdef::__construct * @covers databox_subdef::getSpecs * @covers databox_subdef::getOptions * @covers databox_subdef::buildAudioSubdef */ public function testAudio() { $xml = ' /home/datas/noweb/db_alch_phrasea/video/ audio '; $type = new \Alchemy\Phrasea\Media\Type\Audio(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Audio', $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option); } } /** * @covers databox_subdef::__construct * @covers databox_subdef::getSpecs * @covers databox_subdef::getOptions * @covers databox_subdef::buildFlexPaperSubdef */ public function testFlexPaper() { $xml = ' /home/datas/noweb/db_alch_phrasea/video/ flexpaper '; $type = new \Alchemy\Phrasea\Media\Type\Flash(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->getMock('Symfony\Component\Translation\TranslatorInterface')); $this->assertInstanceOf('\\MediaAlchemyst\\Specification\\Flash', $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType', $option); } } /** * @dataProvider getVariouasTypeAndSubdefs * @covers databox_subdef::getAvailableSubdefTypes */ public function testGetAvailableSubdefTypes($object) { foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf('\\Alchemy\\Phrasea\\Media\\Subdef\\Subdef', $type); } } public function getVariouasTypeAndSubdefs() { $xmlImage = ' /home/datas/noweb/db_alch_phrasea/video/ image '; $typeAudio = new \Alchemy\Phrasea\Media\Type\Audio(); $typeDocument = new \Alchemy\Phrasea\Media\Type\Document(); $typeVideo = new \Alchemy\Phrasea\Media\Type\Video(); return [ [new databox_subdef($typeAudio, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], [new databox_subdef($typeDocument, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], [new databox_subdef($typeVideo, simplexml_load_string($xmlImage), $this->getMock('Symfony\Component\Translation\TranslatorInterface'))], ]; } }