diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 91fffcb6d..8d2b9b226 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -1926,4 +1926,34 @@ class ObjectHydratorTest extends HydrationTestCase $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); $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); + } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index 44823fa51..459ce9ba1 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -66,15 +66,18 @@ class SimpleObjectHydratorTest extends HydrationTestCase 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->addMetaResult('p', 'discr', 'discr'); $rsm->setDiscriminatorColumn('p', 'discr'); + $resultSet = array( array( - 'u__id' => '1', - 'u__name' => 'Fabio B. Silva', + 'p__id' => '1', + 'p__name' => 'Fabio B. Silva', 'discr' => 'subworker' ), );