本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::setId方法的具体用法?PHP Item::setId怎么用?PHP Item::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikibase\DataModel\Entity\Item
的用法示例。
在下文中一共展示了Item::setId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setIdFromSerialization
private function setIdFromSerialization(array $serialization, Item $item)
{
if (!array_key_exists('id', $serialization)) {
return;
}
$item->setId($this->entityIdDeserializer->deserialize($serialization['id']));
}
示例2: testEmptyItem
/**
* @depends testCreateItem
*/
public function testEmptyItem()
{
$factory = $factory = TestEnvironment::newDefault()->getFactory();
self::$localItem = new Item();
self::$localItem->setId(self::$itemId);
$newItem = $factory->newRevisionSaver()->save(new Revision(new ItemContent(self::$localItem)));
$this->assertTrue(self::$localItem->equals($newItem));
}
示例3: newItem
private function newItem()
{
$item = new Item();
$item->setId(1337);
$item->setFingerprint($this->newFingerprint());
$item->setSiteLinkList($this->newSiteLinks());
$this->addStatements($item);
return $item;
}
示例4: testAttemptSave
public function testAttemptSave()
{
$mockApiBase = $this->getMockApiBase();
$mockApiBase->expects($this->once())->method('isWriteMode')->will($this->returnValue(true));
$mockApiBase->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($this->newContext()));
$mockApiBase->expects($this->atLeastOnce())->method('extractRequestParams')->will($this->returnValue(array()));
$helper = new EntitySavingHelper($mockApiBase, $this->getMockErrorReporter(), $this->getMockSummaryFormatter(), $this->getMockEditEntityFactory(1));
$entity = new Item();
$entity->setId(new ItemId('Q444'));
$entity->getFingerprint()->setLabel('en', 'Foo');
$entity->getSiteLinkList()->addNewSiteLink('enwiki', 'APage');
$entity->getStatements()->addNewStatement(new PropertyNoValueSnak(new PropertyId('P8')));
$summary = 'A String Summary';
$flags = 0;
$status = $helper->attemptSaveEntity($entity, $summary, $flags);
$this->assertTrue($status->isGood());
}
示例5: serializationProvider
public function serializationProvider()
{
$provider = array(array(array('type' => 'item', 'labels' => array(), 'descriptions' => array(), 'aliases' => array(), 'sitelinks' => array(), 'claims' => array()), new Item()));
$entity = new Item();
$entity->setId(42);
$provider[] = array(array('type' => 'item', 'id' => 'Q42', 'claims' => array(), 'labels' => array(), 'descriptions' => array(), 'aliases' => array(), 'sitelinks' => array()), $entity);
$entity = new Item();
$entity->getFingerprint()->setLabel('en', 'foo');
$provider[] = array(array('type' => 'item', 'claims' => array(), 'labels' => array('en' => array('lang' => 'en', 'value' => 'foo')), 'descriptions' => array(), 'aliases' => array(), 'sitelinks' => array()), $entity);
$entity = new Item();
$entity->getFingerprint()->setDescription('en', 'foo');
$provider[] = array(array('type' => 'item', 'claims' => array(), 'labels' => array(), 'descriptions' => array('en' => array('lang' => 'en', 'value' => 'foo')), 'aliases' => array(), 'sitelinks' => array()), $entity);
$entity = new Item();
$entity->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
$provider[] = array(array('type' => 'item', 'claims' => array(), 'labels' => array(), 'descriptions' => array(), 'aliases' => array('en' => array('lang' => 'en', 'values' => array('foo', 'bar'))), 'sitelinks' => array()), $entity);
$entity = new Item();
$entity->getStatements()->addNewStatement(new PropertyNoValueSnak(42), null, null, 'test');
$provider[] = array(array('type' => 'item', 'claims' => array('P42' => array(array('mainsnak' => array('snaktype' => 'novalue', 'property' => 'P42'), 'type' => 'statement', 'rank' => 'normal'))), 'labels' => array(), 'descriptions' => array(), 'aliases' => array(), 'sitelinks' => array()), $entity);
$item = new Item();
$item->addSiteLink(new SiteLink('enwiki', 'Nyan Cat'));
$provider[] = array(array('type' => 'item', 'sitelinks' => array('enwiki' => array('site' => 'enwiki', 'title' => 'Nyan Cat', 'badges' => array())), 'labels' => array(), 'descriptions' => array(), 'aliases' => array(), 'claims' => array()), $item);
return $provider;
}
示例6: setUpEntities
private function setUpEntities()
{
global $wgUser;
static $setup = false;
if ($setup) {
return;
}
$setup = true;
$store = WikibaseRepo::getDefaultInstance()->getStore()->getEntityStore();
// remove entities we care about
$idsToDelete = array(new ItemId('Q404'), new ItemId('Q23'));
foreach ($idsToDelete as $id) {
try {
$store->deleteEntity($id, 'test', $wgUser);
} catch (StorageException $ex) {
// ignore
}
}
// set up Q23
$item = new Item();
$item->setId(new ItemId('Q23'));
$item->getFingerprint()->setLabel('en', 'George Washington');
$store->saveEntity($item, 'testing', $wgUser, EDIT_NEW);
}
示例7: testExceptionThrownWhenNormalizingSiteNotFound
public function testExceptionThrownWhenNormalizingSiteNotFound()
{
$from = new Item();
$from->setId(new ItemId('Q111'));
$from->getSiteLinkList()->addNewSiteLink('enwiki', 'FOo');
$to = new Item();
$to->setId(new ItemId('Q222'));
$to->getSiteLinkList()->addNewSiteLink('enwiki', 'Foo');
$changeOps = $this->makeChangeOpsMerge($from, $to, array(), new MockSiteStore());
$this->setExpectedException('\\Wikibase\\ChangeOp\\ChangeOpException', 'Conflicting sitelinks for enwiki, Failed to normalize');
$changeOps->apply();
}
示例8: testGetPermissionStatusForEntity
/**
* @dataProvider provideGetPermissionStatusForEntity
*/
public function testGetPermissionStatusForEntity($action, array $permissions, $id, array $expectations)
{
global $wgUser;
$entity = new Item();
if ($id) {
// "exists"
$entity->setId(new ItemId($id));
}
$this->stashMwGlobals('wgUser');
$this->stashMwGlobals('wgGroupPermissions');
PermissionsHelper::applyPermissions(array('*' => $permissions, 'user' => $permissions, 'autoconfirmed' => $permissions, 'emailconfirmed' => $permissions), array());
$factory = $this->newFactory();
if (isset($expectations['getPermissionStatusForEntity'])) {
$status = $factory->getPermissionStatusForEntity($wgUser, $action, $entity);
$this->assertEquals($expectations['getPermissionStatusForEntity'], $status->isOK());
}
if (isset($expectations['getPermissionStatusForEntityType'])) {
$status = $factory->getPermissionStatusForEntityType($wgUser, $action, $entity->getType());
$this->assertEquals($expectations['getPermissionStatusForEntityType'], $status->isOK());
}
if (isset($expectations['getPermissionStatusForEntityId'])) {
$status = $factory->getPermissionStatusForEntityId($wgUser, $action, $entity->getId());
$this->assertEquals($expectations['getPermissionStatusForEntityId'], $status->isOK());
}
}
示例9: testSetIdUsingNumber
public function testSetIdUsingNumber()
{
$item = new Item();
$item->setId(42);
$this->assertEquals(new ItemId('Q42'), $item->getId());
}