public function testCreateMediaInstance() { $fileTmp = dirname(__DIR__) . '/sample/Brazil.png'; $this->initializeMock($fileTmp); $lang = 'EN-en'; $classUri = $this->testClass->getUri(); //clear previous tests $root = new \core_kernel_classes_Class($classUri); $link = $this->mediaService->createMediaInstance($fileTmp, $classUri, $lang); $root = new \core_kernel_classes_Class($classUri); $instances = $root->getInstances(); /** @var \core_kernel_classes_Resource $instance */ $instance = array_pop($instances); $thing = $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK)); $linkResult = $thing instanceof \core_kernel_classes_Resource ? $thing->getUri() : (string) $thing; $this->assertInstanceOf('\\core_kernel_classes_Resource', $instance, 'It should create an instance under the class in parameter'); $this->assertEquals('Brazil.png', $instance->getLabel(), 'The instance label is wrong'); $this->assertInternalType('string', $link, 'The method return should be a string'); $this->assertEquals($instance->getUri(), $link, 'The instance link is wrong'); $this->assertEquals($linkResult, 'MyGreatLink', 'The returned link is wrong'); $this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong'); $root->delete(true); $root->setSubClassOf($this->mediaService->getRootClass()); }