translator = $this->getMock(TranslatorInterface::class); } public function testImage() { $xml = ' /home/datas/noweb/db_alch_phrasea/subdefs/ yes image 1000 150 no 75 '; $type = new Type\Image(); $object = new databox_subdef($type, simplexml_load_string($xml), $this->translator); $this->assertEquals(databox_subdef::CLASS_PREVIEW, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/subdefs/', $object->get_path()); $this->assertInstanceOf(Subdef\Subdef::class, $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->isDownloadable()); $this->assertTrue(is_array($object->getAvailableSubdefTypes())); $this->assertTrue(count($object->getAvailableSubdefTypes()) > 0); foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf(Subdef\Image::class, $type); } $this->assertTrue($object->isMetadataUpdateRequired()); $this->assertEquals('preview_api', $object->get_name()); $this->assertInstanceOf(Specification\Image::class, $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf(OptionType::class, $option); } } 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->translator); $this->assertEquals(databox_subdef::CLASS_THUMBNAIL, $object->get_class()); $this->assertEquals('/home/datas/noweb/db_alch_phrasea/video/', $object->get_path()); $this->assertInstanceOf(Subdef\Subdef::class, $object->getSubdefType()); $this->assertEquals($type, $object->getSubdefGroup()); $labels = $object->get_labels(); $this->assertTrue(is_array($labels)); $this->assertEquals(0, count($labels)); $this->assertFalse($object->isDownloadable()); $this->assertTrue(is_array($object->getAvailableSubdefTypes())); $this->assertTrue(count($object->getAvailableSubdefTypes()) > 0); foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf(Subdef\Subdef::class, $type); } $this->assertFalse($object->isMetadataUpdateRequired()); $this->assertEquals('video_api', $object->get_name()); $this->assertInstanceOf(Specification\Video::class, $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf(OptionType::class, $option); } } 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->translator); $this->assertInstanceOf(Specification\Animation::class, $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf(OptionType::class, $option); } } 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->translator); $this->assertInstanceOf(Specification\Audio::class, $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf(OptionType::class, $option); } } 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->translator); $this->assertInstanceOf(Specification\Flash::class, $object->getSpecs()); $options = $object->getOptions(); $this->assertTrue(is_array($options)); foreach ($options as $option) { $this->assertInstanceOf(OptionType::class, $option); } } /** * @dataProvider getVariouasTypeAndSubdefs */ public function testGetAvailableSubdefTypes($object) { foreach ($object->getAvailableSubdefTypes() as $type) { $this->assertInstanceOf(Subdef\Subdef::class, $type); } } public function getVariouasTypeAndSubdefs() { $xmlImage = ' /home/datas/noweb/db_alch_phrasea/video/ image '; $translator = $this->getMock(TranslatorInterface::class); return [ [new databox_subdef(new Type\Audio(), simplexml_load_string($xmlImage), $translator)], [new databox_subdef(new Type\Document(), simplexml_load_string($xmlImage), $translator)], [new databox_subdef(new Type\Video(), simplexml_load_string($xmlImage), $translator)], ]; } }