ontology = $this->createMock(Ontology::class); $this->subject = new SharedStimulusResourceSpecification(); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ Ontology::SERVICE_ID => $this->ontology ] ) ); } public function testIsSatisfiedBy(): void { $this->assertTrue( $this->subject->isSatisfiedBy($this->expectsResourceWithMimeType(MediaService::SHARED_STIMULUS_MIME_TYPE)) ); } public function testIsNotSatisfiedBy(): void { $this->assertFalse( $this->subject->isSatisfiedBy($this->expectsResourceWithMimeType('image/jpg')) ); } public function testIsNotSatisfiedByWhenEmptyProperty(): void { $resource = $this->createMock(core_kernel_classes_Resource::class); $property = $this->createMock(core_kernel_classes_Property::class); $this->ontology ->method('getProperty') ->willThrowException(new core_kernel_classes_EmptyProperty($resource, $property)); $this->assertFalse($this->subject->isSatisfiedBy($resource)); } private function expectsResourceWithMimeType(string $mimeType): core_kernel_classes_Resource { $this->ontology ->method('getProperty') ->willReturn($this->createMock(core_kernel_classes_Property::class)); $resource = $this->createMock(core_kernel_classes_Resource::class); $resource->method('getUniquePropertyValue') ->willReturn(new core_kernel_classes_Literal($mimeType)); return $resource; } }