public function testGetItemForIdWithoutDocument() { $itemLookupMock = $this->getMockBuilder('Wikibase\\DataModel\\Services\\Lookup\\ItemLookup')->disableOriginalConstructor()->getMock(); $itemLookupMock->expects($this->once())->method('getItemForId')->with($this->equalTo(new ItemId('Q1')))->willReturn(null); $entityDocumentCacheMock = $this->getMockBuilder('Wikibase\\EntityStore\\Cache\\EntityDocumentCache')->disableOriginalConstructor()->getMock(); $entityDocumentCacheMock->expects($this->once())->method('fetch')->with($this->equalTo(new ItemId('Q1')))->willReturn(null); $entityLookup = new CachedItemLookup($itemLookupMock, $entityDocumentCacheMock); $this->assertNull($entityLookup->getItemForId(new ItemId('Q1'))); }
public function testGetItemForIdWithException() { $itemLookupMock = $this->getMockBuilder('Wikibase\\DataModel\\Entity\\ItemLookup')->disableOriginalConstructor()->getMock(); $itemLookupMock->expects($this->once())->method('getItemForId')->with($this->equalTo(new ItemId('Q1')))->willThrowException(new ItemNotFoundException(new ItemId('Q1'))); $entityDocumentCacheMock = $this->getMockBuilder('Wikibase\\EntityStore\\Cache\\EntityDocumentCache')->disableOriginalConstructor()->getMock(); $entityDocumentCacheMock->expects($this->once())->method('fetch')->with($this->equalTo(new ItemId('Q1')))->willThrowException(new EntityNotFoundException(new ItemId('Q1'))); $entityLookup = new CachedItemLookup($itemLookupMock, $entityDocumentCacheMock); $this->setExpectedException('Wikibase\\DataModel\\Entity\\ItemNotFoundException'); $entityLookup->getItemForId(new ItemId('Q1')); }