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


PHP Item::copy方法代码示例

本文整理汇总了PHP中Wikibase\DataModel\Entity\Item::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::copy方法的具体用法?PHP Item::copy怎么用?PHP Item::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wikibase\DataModel\Entity\Item的用法示例。


在下文中一共展示了Item::copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGivenEmptyDiffItemRemainsUnchanged

 /**
  * @dataProvider itemProvider
  */
 public function testGivenEmptyDiffItemRemainsUnchanged(Item $item)
 {
     $patcher = new EntityPatcher();
     $patchedEntity = $item->copy();
     $patcher->patchEntity($patchedEntity, new ItemDiff());
     $this->assertEquals($item, $patchedEntity);
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:10,代码来源:EntityPatcherTest.php

示例2: getPatchedItem

 private function getPatchedItem(Item $item, ItemDiff $patch)
 {
     $patchedItem = $item->copy();
     $patcher = new ItemPatcher();
     $patcher->patchEntity($patchedItem, $patch);
     return $patchedItem;
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:7,代码来源:ItemPatcherTest.php

示例3: provideApplyData

 public function provideApplyData()
 {
     $originalTests = $this->generateApplyData(Item::ENTITY_TYPE);
     $tests = array();
     /**
      * @var Item $a
      * @var Item $b
      */
     // add link ------------------------------
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42'), new ItemId('Q3')));
     $b = $a->copy();
     $b->getSiteLinkList()->addNewSiteLink('dewiki', 'Test', array(new ItemId('Q42')));
     $tests[] = array($a, $b);
     // add badges
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42')));
     $b = new Item();
     $b->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42'), new ItemId('Q3')));
     $tests[] = array($a, $b);
     // remove badges
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42'), new ItemId('Q3')));
     $b = new Item();
     $b->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42')));
     // modify badges
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q41'), new ItemId('Q3')));
     $b = new Item();
     $b->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42'), new ItemId('Q3')));
     $tests[] = array($a, $b);
     // remove link
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42')));
     $a->getSiteLinkList()->addNewSiteLink('dewiki', 'Test', array(new ItemId('Q3')));
     $b = $a->copy();
     $b->getSiteLinkList()->removeLinkWithSiteId('enwiki');
     $tests[] = array($a, $b);
     // change link
     $a = new Item();
     $a->getSiteLinkList()->addNewSiteLink('enwiki', 'Test', array(new ItemId('Q42'), new ItemId('Q3')));
     $b = new Item();
     $b->getSiteLinkList()->addNewSiteLink('enwiki', 'Test!!!', array(new ItemId('Q42'), new ItemId('Q3')));
     $tests[] = array($a, $b);
     return array_merge($originalTests, $tests);
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:46,代码来源:ItemDiffTest.php

示例4: provideData

 /**
  * @return array 1=>from 2=>to 3=>expectedFrom 4=>expectedTo
  */
 public function provideData()
 {
     $testCases = array();
     $itemWithEnLabel = new Item();
     $itemWithEnLabel->getFingerprint()->setLabel('en', 'foo');
     $testCases['labelMerge'] = array($itemWithEnLabel->copy(), new Item(), new Item(), $itemWithEnLabel->copy());
     $testCases['identicalLabelMerge'] = array($itemWithEnLabel->copy(), $itemWithEnLabel->copy(), new Item(), $itemWithEnLabel->copy());
     $itemWithEnBarLabel = new Item();
     $itemWithEnBarLabel->getFingerprint()->setLabel('en', 'bar');
     $itemWithLabelAndAlias = new Item();
     $itemWithLabelAndAlias->getFingerprint()->setLabel('en', 'bar');
     $itemWithLabelAndAlias->getFingerprint()->setAliasGroup('en', array('foo'));
     $testCases['labelAsAliasMerge'] = array($itemWithEnLabel->copy(), $itemWithEnBarLabel->copy(), new Item(), $itemWithLabelAndAlias->copy());
     $itemWithDescription = new Item();
     $itemWithDescription->getFingerprint()->setDescription('en', 'foo');
     $testCases['descriptionMerge'] = array($itemWithDescription->copy(), new Item(), new Item(), $itemWithDescription->copy());
     $testCases['identicalDescriptionMerge'] = array($itemWithDescription->copy(), $itemWithDescription->copy(), new Item(), $itemWithDescription->copy());
     $itemWithBarDescription = new Item();
     $itemWithBarDescription->getFingerprint()->setDescription('en', 'bar');
     $testCases['ignoreConflictDescriptionMerge'] = array($itemWithDescription->copy(), $itemWithBarDescription->copy(), $itemWithDescription->copy(), $itemWithBarDescription->copy(), array('description'));
     $itemWithFooBarAliases = new Item();
     $itemWithFooBarAliases->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
     $testCases['aliasMerge'] = array($itemWithFooBarAliases->copy(), new Item(), new Item(), $itemWithFooBarAliases->copy());
     $itemWithFooBarBazAliases = new Item();
     $itemWithFooBarBazAliases->getFingerprint()->setAliasGroup('en', array('foo', 'bar', 'baz'));
     $testCases['duplicateAliasMerge'] = array($itemWithFooBarAliases->copy(), $itemWithFooBarBazAliases->copy(), new Item(), $itemWithFooBarBazAliases->copy());
     $itemWithLink = new Item();
     $itemWithLink->getSiteLinkList()->addNewSiteLink('enwiki', 'foo');
     $testCases['linkMerge'] = array($itemWithLink->copy(), new Item(), new Item(), $itemWithLink->copy());
     $testCases['sameLinkLinkMerge'] = array($itemWithLink->copy(), $itemWithLink->copy(), new Item(), $itemWithLink->copy());
     $itemWithBarLink = new Item();
     $itemWithBarLink->getSiteLinkList()->addNewSiteLink('enwiki', 'bar');
     $testCases['ignoreConflictLinkMerge'] = array($itemWithLink->copy(), $itemWithBarLink->copy(), $itemWithLink->copy(), $itemWithBarLink->copy(), array('sitelink'));
     $statement = new Statement(new PropertyNoValueSnak(new PropertyId('P56')));
     $statement->setGuid('Q111$D8404CDA-25E4-4334-AF13-A390BCD9C556');
     $itemWithStatement = new Item();
     $itemWithStatement->getStatements()->addStatement($statement);
     $testCases['statementMerge'] = array($itemWithStatement->copy(), new Item(), new Item(), $itemWithStatement->copy());
     $qualifiedStatement = new Statement(new PropertyNoValueSnak(new PropertyId('P56')), new SnakList(array(new PropertyNoValueSnak(new PropertyId('P56')))));
     $qualifiedStatement->setGuid('Q111$D8404CDA-25E4-4334-AF13-A390BCD9C556');
     $itemWithQualifiedStatement = new Item();
     $itemWithQualifiedStatement->getStatements()->addStatement($qualifiedStatement);
     $testCases['statementWithQualifierMerge'] = array($itemWithQualifiedStatement->copy(), new Item(), new Item(), $itemWithQualifiedStatement->copy());
     $anotherQualifiedStatement = new Statement(new PropertyNoValueSnak(new PropertyId('P88')), new SnakList(array(new PropertyNoValueSnak(new PropertyId('P88')))));
     $anotherQualifiedStatement->setGuid('Q111$D8404CDA-25E4-4334-AF88-A3290BCD9C0F');
     $selfReferencingStatement = new Statement(new PropertyValueSnak(new PropertyId('P42'), new EntityIdValue(new ItemId('Q111'))));
     $selfReferencingStatement->setGuid('Q111$D74D43D7-BD8F-4240-A058-24C5171ABBFA');
     $bigItem = new Item();
     $bigItem->setId(111);
     $bigItem->getFingerprint()->setLabel('en', 'foo');
     $bigItem->getFingerprint()->setLabel('pt', 'ptfoo');
     $bigItem->getFingerprint()->setDescription('en', 'foo');
     $bigItem->getFingerprint()->setDescription('pl', 'pldesc');
     $bigItem->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
     $bigItem->getFingerprint()->setAliasGroup('de', array('defoo', 'debar'));
     $bigItem->getSiteLinkList()->addNewSiteLink('dewiki', 'foo');
     $bigItem->getStatements()->addStatement($anotherQualifiedStatement);
     $bigItem->getStatements()->addStatement($selfReferencingStatement);
     $testCases['itemMerge'] = array($bigItem->copy(), new Item(), new Item(), $bigItem->copy());
     $referencingStatement = new Statement(new PropertyValueSnak(new PropertyId('P42'), new EntityIdValue(new ItemId('Q222'))));
     $referencingStatement->setGuid('Q111$949A4D27-0EBC-46A7-BF5F-AA2DD33C0443');
     $bigItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'bar');
     $bigItem->getStatements()->addStatement($referencingStatement);
     $smallerItem = new Item();
     $smallerItem->setId(222);
     $smallerItem->getFingerprint()->setLabel('en', 'toLabel');
     $smallerItem->getFingerprint()->setDescription('pl', 'toDescription');
     $smallerItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'toLink');
     $smallerMergedItem = new Item();
     $smallerMergedItem->setId(222);
     $smallerMergedItem->getFingerprint()->setDescription('pl', 'pldesc');
     $smallerMergedItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'bar');
     $bigMergedItem = new Item();
     $bigMergedItem->setId(111);
     $bigMergedItem->getFingerprint()->setLabel('en', 'toLabel');
     $bigMergedItem->getFingerprint()->setLabel('pt', 'ptfoo');
     $bigMergedItem->getFingerprint()->setDescription('en', 'foo');
     $bigMergedItem->getFingerprint()->setDescription('pl', 'toDescription');
     $bigMergedItem->getFingerprint()->setAliasGroup('en', array('foo', 'bar'));
     $bigMergedItem->getFingerprint()->setAliasGroup('de', array('defoo', 'debar'));
     $bigMergedItem->getSiteLinkList()->addNewSiteLink('dewiki', 'foo');
     $bigMergedItem->getSiteLinkList()->addNewSiteLink('nlwiki', 'toLink');
     $bigMergedItem->setStatements(new StatementList($anotherQualifiedStatement, $selfReferencingStatement, $referencingStatement));
     $testCases['ignoreConflictItemMerge'] = array($bigItem->copy(), $smallerItem->copy(), $smallerMergedItem->copy(), $bigMergedItem->copy(), array('description', 'sitelink', 'statement'));
     return $testCases;
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:89,代码来源:ChangeOpsMergeTest.php

示例5: equalsProvider

 public function equalsProvider()
 {
     $firstItem = new Item();
     $firstItem->getStatements()->addNewStatement(new PropertyNoValueSnak(42));
     $secondItem = new Item();
     $secondItem->getStatements()->addNewStatement(new PropertyNoValueSnak(42));
     $secondItemWithId = $secondItem->copy();
     $secondItemWithId->setId(42);
     $differentId = $secondItemWithId->copy();
     $differentId->setId(43);
     return array(array(new Item(), new Item()), array($firstItem, $secondItem), array($secondItem, $secondItemWithId), array($secondItemWithId, $differentId));
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:12,代码来源:ItemTest.php

示例6: testCopyRetainsLabels

 public function testCopyRetainsLabels()
 {
     $item = new Item();
     $item->getFingerprint()->setLabel('en', 'foo');
     $item->getFingerprint()->setLabel('de', 'bar');
     $newItem = $item->copy();
     $this->assertTrue($newItem->getFingerprint()->getLabels()->hasTermForLanguage('en'));
     $this->assertTrue($newItem->getFingerprint()->getLabels()->hasTermForLanguage('de'));
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:9,代码来源:EntityTest.php


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