当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::setId方法代码示例

本文整理汇总了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']));
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:7,代码来源:ItemDeserializer.php

示例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));
 }
开发者ID:hakanozdemir,项目名称:wikibase-api,代码行数:11,代码来源:IntegrationTest.php

示例3: newItem

 private function newItem()
 {
     $item = new Item();
     $item->setId(1337);
     $item->setFingerprint($this->newFingerprint());
     $item->setSiteLinkList($this->newSiteLinks());
     $this->addStatements($item);
     return $item;
 }
开发者ID:queryr,项目名称:serialization,代码行数:9,代码来源:SimpleItemBuilderTest.php

示例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());
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:17,代码来源:EntitySavingHelperTest.php

示例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;
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:23,代码来源:ItemSerializerTest.php

示例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);
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:24,代码来源:FormatSnakValueTest.php

示例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();
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:12,代码来源:ChangeOpsMergeTest.php

示例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());
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:28,代码来源:EntityContentFactoryTest.php

示例9: testSetIdUsingNumber

 public function testSetIdUsingNumber()
 {
     $item = new Item();
     $item->setId(42);
     $this->assertEquals(new ItemId('Q42'), $item->getId());
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:6,代码来源:ItemTest.php


注:本文中的Wikibase\DataModel\Entity\Item::setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。