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


PHP ClassMetadata::setDistance方法代码示例

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


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

示例1: testClassMetadataInstanceSerialization

 public function testClassMetadataInstanceSerialization()
 {
     $cm = new ClassMetadata('Documents\\CmsUser');
     // Test initial state
     $this->assertTrue(count($cm->getReflectionProperties()) == 0);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Documents\\CmsUser', $cm->name);
     $this->assertEquals('Documents\\CmsUser', $cm->rootDocumentName);
     $this->assertEquals(array(), $cm->subClasses);
     $this->assertEquals(array(), $cm->parentClasses);
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType);
     // Customize state
     $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_COLLECTION);
     $cm->setSubclasses(array("One", "Two", "Three"));
     $cm->setParentClasses(array("UserParent"));
     $cm->setCustomRepositoryClass("UserRepository");
     $cm->setDiscriminatorField('disc');
     $cm->mapOneEmbedded(array('fieldName' => 'phonenumbers', 'targetDocument' => 'Bar'));
     $cm->setFile('customFileProperty');
     $cm->setDistance('customDistanceProperty');
     $cm->setSlaveOkay(true);
     $cm->setShardKey(array('_id' => '1'));
     $cm->setCollectionCapped(true);
     $cm->setCollectionMax(1000);
     $cm->setCollectionSize(500);
     $this->assertTrue(is_array($cm->getFieldMapping('phonenumbers')));
     $this->assertEquals(1, count($cm->fieldMappings));
     $this->assertEquals(1, count($cm->associationMappings));
     $serialized = serialize($cm);
     $cm = unserialize($serialized);
     // Check state
     $this->assertTrue(count($cm->getReflectionProperties()) > 0);
     $this->assertEquals('Documents', $cm->namespace);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Documents\\CmsUser', $cm->name);
     $this->assertEquals('UserParent', $cm->rootDocumentName);
     $this->assertEquals(array('Documents\\One', 'Documents\\Two', 'Documents\\Three'), $cm->subClasses);
     $this->assertEquals(array('UserParent'), $cm->parentClasses);
     $this->assertEquals('Documents\\UserRepository', $cm->customRepositoryClassName);
     $this->assertEquals('disc', $cm->discriminatorField);
     $this->assertTrue(is_array($cm->getFieldMapping('phonenumbers')));
     $this->assertEquals(1, count($cm->fieldMappings));
     $this->assertEquals(1, count($cm->associationMappings));
     $this->assertEquals('customFileProperty', $cm->file);
     $this->assertEquals('customDistanceProperty', $cm->distance);
     $this->assertTrue($cm->slaveOkay);
     $this->assertEquals(array('keys' => array('_id' => 1), 'options' => array()), $cm->getShardKey());
     $mapping = $cm->getFieldMapping('phonenumbers');
     $this->assertEquals('Documents\\Bar', $mapping['targetDocument']);
     $this->assertTrue($cm->getCollectionCapped());
     $this->assertEquals(1000, $cm->getCollectionMax());
     $this->assertEquals(500, $cm->getCollectionSize());
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:53,代码来源:ClassMetadataTest.php


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