/**
  * @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 newItem()
 {
     $item = new Item();
     $item->setId(1337);
     $item->setFingerprint($this->newFingerprint());
     $item->setSiteLinkList($this->newSiteLinks());
     $this->addStatements($item);
     return $item;
 }
 private function fingerprintCaseToEntityCase(array $fingerprintCase, ItemId $id)
 {
     $fingerprint = reset($fingerprintCase);
     $item = new Item($id);
     $item->setFingerprint($fingerprint);
     $entityCase = $fingerprintCase;
     $entityCase[0] = $item;
     return $entityCase;
 }
 /**
  * @dataProvider executeProvider
  */
 public function testExecute(Fingerprint $inputFingerprint, $subpage, WebRequest $request = null, array $tagMatchers, Fingerprint $expectedFingerprint = null)
 {
     $inputEntity = new Item();
     $inputEntity->setFingerprint($inputFingerprint);
     $this->mockRepository->putEntity($inputEntity);
     $id = $inputEntity->getId();
     $subpage = str_replace('$id', $id->getSerialization(), $subpage);
     list($output, $response) = $this->executeSpecialPage($subpage, $request);
     $redirect = $response instanceof FauxResponse ? $response->getHeader('Location') : null;
     foreach ($tagMatchers as $key => $matcher) {
         $this->assertTag($matcher, $output, "Failed to assert output: {$key}");
     }
     if ($expectedFingerprint !== null) {
         // TODO: Look for an error message in $output.
         $this->assertNotEmpty($redirect, 'Expected redirect after successful edit');
         /** @var Item $actualEntity */
         $actualEntity = $this->mockRepository->getEntity($id);
         $actualFingerprint = $actualEntity->getFingerprint();
         $this->assetFingerprintEquals($expectedFingerprint, $actualFingerprint);
     }
 }
Пример #5
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')));
 }