Skip to content

Let ReflectionException bubble #1320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ public function mapField(array $mapping)
{
$mapping = parent::mapField($mapping);

if ($this->reflClass->hasProperty($mapping['fieldName'])) {
$reflProp = $this->reflClass->getProperty($mapping['fieldName']);
$reflProp->setAccessible(true);
$this->reflFields[$mapping['fieldName']] = $reflProp;
}
$reflProp = $this->reflClass->getProperty($mapping['fieldName']);
$reflProp->setAccessible(true);
$this->reflFields[$mapping['fieldName']] = $reflProp;
}

/**
Expand Down
15 changes: 12 additions & 3 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ public function testSetSubClassesInGlobalNamespace()
public function testDuplicateFieldMapping()
{
$cm = new ClassMetadata('Documents\CmsUser');
$a1 = array('reference' => true, 'type' => 'many', 'fieldName' => 'foo', 'targetDocument' => 'stdClass');
$a2 = array('type' => 'string', 'fieldName' => 'foo');
$a1 = array('reference' => true, 'type' => 'many', 'fieldName' => 'name', 'targetDocument' => 'stdClass');
$a2 = array('type' => 'string', 'fieldName' => 'name');

$cm->mapField($a1);
$cm->mapField($a2);

$this->assertEquals('string', $cm->fieldMappings['foo']['type']);
$this->assertEquals('string', $cm->fieldMappings['name']['type']);
}

public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException()
Expand Down Expand Up @@ -195,4 +195,13 @@ public function testDuplicateFieldAndAssocationMapping2()

$this->assertEquals('string', $cm->fieldMappings['name']['type']);
}

/**
* @expectedException \ReflectionException
*/
public function testMapNotExistingFieldThrowsException()
{
$cm = new ClassMetadata('Documents\CmsUser');
$cm->mapField(array('fieldName' => 'namee', 'columnName' => 'name', 'type' => 'string'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class User

protected $account;

protected $tags = array();

protected $test;

public function __construct()
{
$this->phonenumbers = new \Doctrine\Common\Collections\ArrayCollection();
Expand Down