public function testGetPropertyForIdWithException() { $propertyLookupMock = $this->getMockBuilder('Wikibase\\DataModel\\Services\\Lookup\\PropertyLookup')->disableOriginalConstructor()->getMock(); $propertyLookupMock->expects($this->once())->method('getPropertyForId')->with($this->equalTo(new PropertyId('P1')))->willReturn(null); $entityDocumentCacheMock = $this->getMockBuilder('Wikibase\\EntityStore\\Cache\\EntityDocumentCache')->disableOriginalConstructor()->getMock(); $entityDocumentCacheMock->expects($this->once())->method('fetch')->with($this->equalTo(new PropertyId('P1')))->willReturn(null); $entityLookup = new CachedPropertyLookup($propertyLookupMock, $entityDocumentCacheMock); $this->assertNull($entityLookup->getPropertyForId(new PropertyId('P1'))); }
public function testGetPropertyForIdWithException() { $propertyLookupMock = $this->getMockBuilder('Wikibase\\DataModel\\Entity\\PropertyLookup')->disableOriginalConstructor()->getMock(); $propertyLookupMock->expects($this->once())->method('getPropertyForId')->with($this->equalTo(new PropertyId('P1')))->willThrowException(new PropertyNotFoundException(new PropertyId('P1'))); $entityDocumentCacheMock = $this->getMockBuilder('Wikibase\\EntityStore\\Cache\\EntityDocumentCache')->disableOriginalConstructor()->getMock(); $entityDocumentCacheMock->expects($this->once())->method('fetch')->with($this->equalTo(new PropertyId('P1')))->willThrowException(new EntityNotFoundException(new PropertyId('P1'))); $entityLookup = new CachedPropertyLookup($propertyLookupMock, $entityDocumentCacheMock); $this->setExpectedException('Wikibase\\DataModel\\Entity\\PropertyNotFoundException'); $entityLookup->getPropertyForId(new PropertyId('P1')); }