private function newSimpleFingerprint()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setLabel('en', 'foo');
     $fingerprint->setDescription('de', 'bar');
     $fingerprint->setAliasGroup('nl', array('baz'));
     return $fingerprint;
 }
 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 generateProvider()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setLabel('en', 'Test');
     $fingerprint->setLabel('de', 'Testen');
     $fingerprint->setDescription('en', 'city in Spain');
     $fingerprint->setAliasGroup('en', array('abc', 'cde'));
     $fingerprint->setAliasGroup('de', array('xyz', 'uvw'));
     $patterns = array('/^Test$/', '/^Testen$/', '/^city in Spain$/', '/^abc$/', '/^cde$/', '/^uvw$/', '/^xyz$/', '/^(?!abcde).*$/');
     return array(array($fingerprint, $patterns));
 }
 public function testGetHtml_valuesAreEscaped()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setDescription('en', '<script>alert( "xss" );</script>');
     $fingerprint->setAliasGroup('en', array('<a href="#">evil html</a>', '<b>bold</b>', '<i>italic</i>'));
     $view = $this->getEntityTermsView(1);
     $html = $view->getHtml($fingerprint, null, '', new TextInjector());
     $this->assertContains('evil html', $html, 'make sure it works');
     $this->assertNotContains('href="#"', $html);
     $this->assertNotContains('<script>', $html);
     $this->assertNotContains('<b>', $html);
     $this->assertNotContains('<i>', $html);
     $this->assertNotContains('&amp;', $html, 'no double escaping');
 }
 /**
  * @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;
 }
Example #7
0
 public function testHasDescriptionReturnsTrueOnlyWhenDescriptionExists()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setDescription('en', 'foo');
     $this->assertTrue($fingerprint->hasDescription('en'));
     $this->assertFalse($fingerprint->hasDescription('de'));
 }
 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')));
 }
Example #9
0
 /**
  * @param string $languageCode
  * @param string $value
  *
  * @throws InvalidArgumentException
  */
 public function setDescription($languageCode, $value)
 {
     $this->fingerprint->setDescription($languageCode, $value);
 }