public function testGetItemModelImplementation() { $itemModelProphecy = $this->prophesize('core_kernel_classes_Resource'); $itemModelProphecy->getPropertyValues(new core_kernel_classes_Property(PROPERTY_ITEM_MODEL_SERVICE))->willReturn(array('#fakeUri', '#toto')); $itemModelProphecy->getLabel()->willReturn('foo'); try { $this->itemsService->getItemModelImplementation($itemModelProphecy->reveal()); $this->fail('an exception should have been raised'); } catch (\common_Exception $e) { $this->assertInstanceOf('common_exception_Error', $e); $this->assertEquals('Conflicting services for itemmodel foo', $e->getMessage()); } $itemModelProphecy->getPropertyValues(new core_kernel_classes_Property(PROPERTY_ITEM_MODEL_SERVICE))->willReturn(array('#fakeUri')); $itemModelProphecy->getLabel()->willReturn('foo'); try { $this->itemsService->getItemModelImplementation($itemModelProphecy->reveal()); $this->fail('an exception should have been raised'); } catch (\common_Exception $e) { $this->assertInstanceOf('common_exception_Error', $e); $this->assertEquals('Item model service #fakeUri not found, or not compatible for item model foo', $e->getMessage()); } $itemModelProphecy->getPropertyValues(new core_kernel_classes_Property(PROPERTY_ITEM_MODEL_SERVICE))->willReturn(array()); $this->assertNull($this->itemsService->getItemModelImplementation($itemModelProphecy->reveal())); }