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));
 }
 private function newSimpleFingerprint()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setLabel('en', 'foo');
     $fingerprint->setDescription('de', 'bar');
     $fingerprint->setAliasGroup('nl', array('baz'));
     return $fingerprint;
 }
 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;
 }
Exemplo n.º 6
0
 public function testHasAliasGroupReturnsTrueOnlyWhenAliasGroupExists()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setAliasGroup('en', array('foo'));
     $this->assertTrue($fingerprint->hasAliasGroup('en'));
     $this->assertFalse($fingerprint->hasAliasGroup('de'));
 }
Exemplo n.º 7
0
 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')));
 }
Exemplo n.º 8
0
 /**
  * @param string $languageCode
  * @param string[] $aliases
  *
  * @throws InvalidArgumentException
  */
 public function setAliases($languageCode, array $aliases)
 {
     $this->fingerprint->setAliasGroup($languageCode, $aliases);
 }