1
0
mirror of synced 2025-01-09 18:47:10 +03:00

[DDC-3076] Add/Improve tests

This commit is contained in:
Frank Liepert 2014-04-09 11:31:16 +02:00
parent df020e08a0
commit 8740d54210
2 changed files with 36 additions and 3 deletions

View File

@ -1926,4 +1926,34 @@ class ObjectHydratorTest extends HydrationTestCase
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$hydrator->hydrateAll($stmt, $rsm); $hydrator->hydrateAll($stmt, $rsm);
} }
/**
* @group DDC-3076
*
* @expectedException \Doctrine\ORM\Internal\Hydration\HydrationException
* @expectedExceptionMessage The discriminator value "subworker" is invalid. It must be one of "person", "manager", "employee".
*/
public function testInvalidDiscriminatorValueException()
{
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p');
$rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'discr', 'discr');
$rsm->setDiscriminatorColumn('p', 'discr');
$resultSet = array(
array(
'p__id' => '1',
'p__name' => 'Fabio B. Silva',
'discr' => 'subworker'
),
);
$stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$hydrator->hydrateAll($stmt, $rsm);
}
} }

View File

@ -66,15 +66,18 @@ class SimpleObjectHydratorTest extends HydrationTestCase
public function testInvalidDiscriminatorValueException() public function testInvalidDiscriminatorValueException()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p'); $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p');
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'discr', 'discr'); $rsm->addMetaResult('p', 'discr', 'discr');
$rsm->setDiscriminatorColumn('p', 'discr'); $rsm->setDiscriminatorColumn('p', 'discr');
$resultSet = array( $resultSet = array(
array( array(
'u__id' => '1', 'p__id' => '1',
'u__name' => 'Fabio B. Silva', 'p__name' => 'Fabio B. Silva',
'discr' => 'subworker' 'discr' => 'subworker'
), ),
); );