本文整理汇总了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));
}