Map a single embedded document.
public mapOneEmbedded ( array $mapping ) | ||
$mapping | array | The mapping information. |
function it_configures_the_mappings_of_an_original_model_that_is_override($configuration) { $metadataInfo = new ClassMetadataInfo('Foo\\Bar\\OriginalQux'); $metadataInfo->mapOneReference(['fieldName' => 'relation1', 'targetEntity' => 'Foo']); $metadataInfo->mapManyReference(['fieldName' => 'relation2', 'targetEntity' => 'Foo']); $metadataInfo->mapOneEmbedded(['fieldName' => 'relation3', 'targetEntity' => 'Foo', 'mappedBy' => 'baz']); $metadataInfo->mapManyEmbedded(['fieldName' => 'relation4', 'targetEntity' => 'Foo']); $overrides = [['original' => 'Foo\\Bar\\OriginalQux', 'override' => 'Acme\\Bar\\OverrideQux'], ['original' => 'Foo\\Baz\\OriginalQux', 'override' => 'Acme\\Baz\\OverrideQux']]; $this->configure($metadataInfo, $overrides, $configuration)->shouldBeAnOverrideModel(); }
/** * @expectedException \Doctrine\ODM\MongoDB\Mapping\MappingException * @expectedExceptionMessage Cascade on Doctrine\ODM\MongoDB\Tests\Mapping\EmbedWithCascadeTest::address is not allowed. */ public function testEmbedWithCascadeThrowsMappingException() { $class = new ClassMetadataInfo(__NAMESPACE__ . '\\EmbedWithCascadeTest'); $class->mapOneEmbedded(array('fieldName' => 'address', 'targetDocument' => 'Documents\\Address', 'cascade' => 'all')); }