/** * @since 2.0 * * @param Snak[]|Snak $snaks * @param Snak [$snak2,...] * * @throws InvalidArgumentException */ public function addNewReference($snaks = array()) { if ($snaks instanceof Snak) { $snaks = func_get_args(); } $this->references->addNewReference($snaks); }
public function testFullEntityGetEntityResponse() { $item = new Item(new ItemId('Q123098')); //Basic $item->setLabel('de', 'foo-de'); $item->setLabel('qu', 'foo-qu'); $item->setAliases('en', array('bar', 'baz')); $item->setAliases('de-formal', array('bar', 'baz')); $item->setDescription('en', 'en-desc'); $item->setDescription('pt', 'ptDesc'); $item->getSiteLinkList()->addNewSiteLink('enwiki', 'Berlin', array(new ItemId('Q333'))); $item->getSiteLinkList()->addNewSiteLink('zh_classicalwiki', 'User:Addshore', array()); $snak = new PropertyValueSnak(65, new StringValue('snakStringValue')); $qualifiers = new SnakList(); $qualifiers->addSnak(new PropertyValueSnak(65, new StringValue('string!'))); $qualifiers->addSnak(new PropertySomeValueSnak(65)); $references = new ReferenceList(); $references->addNewReference(array(new PropertySomeValueSnak(65), new PropertySomeValueSnak(68))); $guid = 'imaguid'; $item->getStatements()->addNewStatement($snak, $qualifiers, $references, $guid); $entityLookup = new MockRepository(); $entityLookup->putEntity($item); $entityAccessor = $this->getEntityAccessor($entityLookup, null, 'qug'); $expected = array('id' => 'Q123098', 'type' => 'item', 'labels' => array('de' => array('language' => 'de', 'value' => 'foo-de')), 'descriptions' => array('en' => array('language' => 'en', 'value' => 'en-desc')), 'aliases' => array('en' => array(1 => array('language' => 'en', 'value' => 'bar'), 2 => array('language' => 'en', 'value' => 'baz'))), 'claims' => array('P65' => array(1 => array('id' => 'imaguid', 'type' => 'statement', 'mainsnak' => array('snaktype' => 'value', 'property' => 'P65', 'datatype' => 'structured-cat', 'datavalue' => array('value' => 'snakStringValue', 'type' => 'string')), 'qualifiers' => array('P65' => array(1 => array('hash' => 'e95e866e7fa1c18bd06dae9b712cb99545107eb8', 'snaktype' => 'value', 'property' => 'P65', 'datavalue' => array('value' => 'string!', 'type' => 'string'), 'datatype' => 'structured-cat'), 2 => array('hash' => '210b00274bf03247a89de918f15b12142ebf9e56', 'snaktype' => 'somevalue', 'property' => 'P65', 'datatype' => 'structured-cat'))), 'rank' => 'normal', 'qualifiers-order' => array(1 => 'P65'), 'references' => array(1 => array('hash' => 'bdc5f7185904d6d3219e13b7443571dda8c4bee8', 'snaks' => array('P65' => array(1 => array('snaktype' => 'somevalue', 'property' => 'P65', 'datatype' => 'structured-cat')), 'P68' => array(1 => array('snaktype' => 'somevalue', 'property' => 'P68', 'datatype' => 'structured-cat'))), 'snaks-order' => array(1 => 'P65', 2 => 'P68')))))), 'sitelinks' => array('enwiki' => array('site' => 'enwiki', 'title' => 'Berlin', 'badges' => array(1 => 'Q333')), 'zh_classicalwiki' => array('site' => 'zh_classicalwiki', 'title' => 'User:Addshore', 'badges' => array())), 'schemaVersion' => 2); $this->assertEquals($expected, $entityAccessor->getEntity('Q123098')); }
public function testGivenNonEmptyListWithForwardedIterator_isNotEmpty() { $references = new ReferenceList(); $references->addNewReference(new PropertyNoValueSnak(1)); $references->next(); $this->assertFalse($references->valid(), 'post condition'); $this->assertFalse($references->isEmpty()); $this->assertFalse($references->valid(), 'pre condition'); }