public function testGetLabels_buffer() { $termIndex = $this->getRestrictedTermIndex(2, 0); $lookup = new BufferingTermLookup($termIndex, 10); $q116 = new ItemId('Q123'); // This should trigger one call to getTermsOfEntity $expected = array('de' => 'Wien', 'en' => 'Vienna'); $this->assertEquals($expected, $lookup->getLabels($q116, array('de', 'en', 'it'))); // This should trigger no more calls, since the label for 'en' is in the buffer $this->assertEquals('Vienna', $lookup->getLabel($q116, 'en')); // This should trigger no more calls to the TermIndex, since the label for 'it' is in the // buffer as a negative entry. $this->assertEquals(array(), $lookup->getLabels($q116, array('it'))); // This should trigger one call to getTermsOfEntity $this->assertEquals('Vienne', $lookup->getLabel($q116, 'fr')); // This should trigger no more calls to the TermIndex, since all languages are in the buffer // now. $expected = array('de' => 'Wien', 'fr' => 'Vienne'); $this->assertEquals($expected, $lookup->getLabels($q116, array('de', 'fr'))); }