private function newCountryProperty() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'country'); $fingerprint->setLabel('nl', 'land'); $fingerprint->setDescription('en', 'sovereign state of this item'); $countryProperty = new Property(new PropertyId('P17'), $fingerprint, 'wikibase-item'); $countryProperty->getStatements()->addNewStatement(new PropertyValueSnak(42, new StringValue('foobar'))); return $countryProperty; }
private function newFingerprint() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'foo'); $fingerprint->setLabel('de', 'bar'); $fingerprint->setLabel('nl', 'baz'); $fingerprint->setDescription('de', 'de description'); $fingerprint->setAliasGroup('en', ['first en alias', 'second en alias']); $fingerprint->setAliasGroup('de', ['first de alias', 'second de alias']); return $fingerprint; }
public function testGivenUntrimmedLabel_generateDoesNotTrim() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', ' untrimmed label '); $generator = new FingerprintSearchTextGenerator(); $text = $generator->generate($fingerprint); $this->assertSame(" untrimmed label ", $text); }
/** * @return Item[] */ public function itemProvider() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'kittens'); $nonEmptyItem = new Item(); $nonEmptyItem->setFingerprint($fingerprint); return array($this->addStatementsAndSave(new Item()), $this->addStatementsAndSave($nonEmptyItem)); }
private function newSimpleFingerprint() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'foo'); $fingerprint->setDescription('de', 'bar'); $fingerprint->setAliasGroup('nl', array('baz')); return $fingerprint; }
/** * @param string[] $labels * @param string[] $descriptions * @param array[] $aliases * * @return Fingerprint */ private function makeFingerprint(array $labels = array(), array $descriptions = array(), array $aliases = array()) { $fingerprint = new Fingerprint(); foreach ($labels as $lang => $text) { $fingerprint->setLabel($lang, $text); } foreach ($descriptions as $lang => $text) { $fingerprint->setDescription($lang, $text); } foreach ($aliases as $lang => $texts) { $fingerprint->setAliasGroup($lang, $texts); } return $fingerprint; }
public function testHasLabelReturnsTrueOnlyWhenLabelExists() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'foo'); $this->assertTrue($fingerprint->hasLabel('en')); $this->assertFalse($fingerprint->hasLabel('de')); }
/** * Construct mock repository matching the test data. * * @return MockRepository */ public function getMockRepository() { static $repo; if (!empty($repo)) { return $repo; } $repo = new MockRepository(); foreach (self::getTestProperties() as $prop) { list($id, $type) = $prop; $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', "Property{$id}"); $entity = new Property(PropertyId::newFromNumber($id), $fingerprint, $type); $repo->putEntity($entity); } $q42 = new ItemId('Q42'); $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'Item42'); $entity = new Item($q42, $fingerprint); $repo->putEntity($entity); $repo->putRedirect(new EntityRedirect(new ItemId('Q4242'), $q42)); return $repo; }
public function getEntityTermsProvider() { $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', 'kittens!!!:)'); $fingerprint->setDescription('es', 'es un gato!'); $fingerprint->setAliasGroup('en', array('kitten-alias')); $item = new Item(new ItemId('Q999')); $item->setFingerprint($fingerprint); $expectedTerms = array(new TermIndexEntry(array('entityId' => 999, 'entityType' => 'item', 'termText' => 'es un gato!', 'termLanguage' => 'es', 'termType' => 'description')), new TermIndexEntry(array('entityId' => 999, 'entityType' => 'item', 'termText' => 'kittens!!!:)', 'termLanguage' => 'en', 'termType' => 'label')), new TermIndexEntry(array('entityId' => 999, 'entityType' => 'item', 'termText' => 'kitten-alias', 'termLanguage' => 'en', 'termType' => 'alias'))); return array(array($expectedTerms, $item), array(array(), new Item()), array(array(), $this->getMock('Wikibase\\DataModel\\Entity\\EntityDocument'))); }
public function testGetTitleHtml_labelIsEscaped() { $entityTermsView = $this->getEntityTermsView(); $fingerprint = new Fingerprint(); $fingerprint->setLabel('en', '<a href="#">evil html</a>'); $html = $entityTermsView->getTitleHtml($fingerprint, null); $this->assertContains('evil html', $html, 'make sure it works'); $this->assertNotContains('href="#"', $html); $this->assertNotContains('&', $html, 'no double escaping'); }
/** * @param string $languageCode * @param string $value * * @throws InvalidArgumentException */ public function setLabel($languageCode, $value) { $this->fingerprint->setLabel($languageCode, $value); }