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


PHP MetadataDescription::setAssocId方法代码示例

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


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

示例1: testMetadataDescriptionCrud

 /**
  * @covers MetadataDescriptionDAO
  *
  * FIXME: The test data used here and in the CitationDAOTest
  * are very similar. We should find a way to not duplicate this
  * test data.
  */
 public function testMetadataDescriptionCrud()
 {
     $metadataDescriptionDao = DAORegistry::getDAO('MetadataDescriptionDAO');
     $nameDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', ASSOC_TYPE_AUTHOR);
     $nameDescription->addStatement('given-names', $value = 'Peter');
     $nameDescription->addStatement('given-names', $value = 'B');
     $nameDescription->addStatement('surname', $value = 'Bork');
     $nameDescription->addStatement('prefix', $value = 'Mr.');
     $testDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema', ASSOC_TYPE_CITATION);
     $testDescription->setAssocId(999999);
     $testDescription->setDisplayName('test meta-data description');
     $testDescription->setSeq(5);
     $testDescription->addStatement('person-group[@person-group-type="author"]', $nameDescription);
     $testDescription->addStatement('article-title', $value = 'PHPUnit in a nutshell', 'en_US');
     $testDescription->addStatement('article-title', $value = 'PHPUnit in Kürze', 'de_DE');
     $testDescription->addStatement('date', $value = '2009-08-17');
     $testDescription->addStatement('size', $value = 320);
     $testDescription->addStatement('uri', $value = 'http://phpunit.org/nutshell');
     // Create meta-data description
     $metadataDescriptionId = $metadataDescriptionDao->insertObject($testDescription);
     self::assertTrue(is_numeric($metadataDescriptionId));
     self::assertTrue($metadataDescriptionId > 0);
     // Retrieve meta-data description by id
     $metadataDescriptionById = $metadataDescriptionDao->getObjectById($metadataDescriptionId);
     $testDescription->removeSupportedMetadataAdapter('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema');
     // Required for comparison
     $metadataDescriptionById->getMetadataSchema();
     // Instantiates the internal metadata-schema.
     self::assertEquals($testDescription, $metadataDescriptionById);
     $metadataDescriptionsByAssocIdDaoFactory = $metadataDescriptionDao->getObjectsByAssocId(ASSOC_TYPE_CITATION, 999999);
     $metadataDescriptionsByAssocId = $metadataDescriptionsByAssocIdDaoFactory->toArray();
     self::assertEquals(1, count($metadataDescriptionsByAssocId));
     $metadataDescriptionsByAssocId[0]->getMetadataSchema();
     // Instantiates the internal metadata-schema.
     self::assertEquals($testDescription, $metadataDescriptionsByAssocId[0]);
     // Update meta-data description
     $testDescription->removeStatement('date');
     $testDescription->addStatement('article-title', $value = 'PHPUnit rápido', 'pt_BR');
     $metadataDescriptionDao->updateObject($testDescription);
     $testDescription->removeSupportedMetadataAdapter('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema');
     // Required for comparison
     $metadataDescriptionAfterUpdate = $metadataDescriptionDao->getObjectById($metadataDescriptionId);
     $metadataDescriptionAfterUpdate->getMetadataSchema();
     // Instantiates the internal metadata-schema.
     self::assertEquals($testDescription, $metadataDescriptionAfterUpdate);
     // Delete meta-data description
     $metadataDescriptionDao->deleteObjectsByAssocId(ASSOC_TYPE_CITATION, 999999);
     self::assertNull($metadataDescriptionDao->getObjectById($metadataDescriptionId));
 }
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:56,代码来源:MetadataDescriptionDAOTest.php


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