|
7 | 7 | use Doctrine\DBAL\Types\Type as DBALType;
|
8 | 8 | use Doctrine\ORM\Internal\Hydration\HydrationException;
|
9 | 9 | use Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator;
|
| 10 | +use Doctrine\ORM\Mapping\MappingException; |
10 | 11 | use Doctrine\ORM\Query\ResultSetMapping;
|
11 | 12 | use Doctrine\Tests\DbalTypes\GH8565EmployeePayloadType;
|
12 | 13 | use Doctrine\Tests\DbalTypes\GH8565ManagerPayloadType;
|
13 | 14 | use Doctrine\Tests\Mocks\ArrayResultFactory;
|
14 | 15 | use Doctrine\Tests\Models\CMS\CmsAddress;
|
15 | 16 | use Doctrine\Tests\Models\Company\CompanyPerson;
|
| 17 | +use Doctrine\Tests\Models\Enums\Scale; |
16 | 18 | use Doctrine\Tests\Models\GH8565\GH8565Employee;
|
17 | 19 | use Doctrine\Tests\Models\GH8565\GH8565Manager;
|
18 | 20 | use Doctrine\Tests\Models\GH8565\GH8565Person;
|
@@ -155,4 +157,23 @@ public function testWrongValuesShouldNotBeConvertedToPhpValue(): void
|
155 | 157 | $result = $hydrator->hydrateAll($stmt, $rsm);
|
156 | 158 | self::assertEquals($result[0], $expectedEntity);
|
157 | 159 | }
|
| 160 | + |
| 161 | + public function testNotListedValueInEnumArray(): void |
| 162 | + { |
| 163 | + $this->expectException(MappingException::class); |
| 164 | + $rsm = new ResultSetMapping(); |
| 165 | + $rsm->addEntityResult(Scale::class, 's'); |
| 166 | + $rsm->addFieldResult('s', 's__id', 'id'); |
| 167 | + $rsm->addFieldResult('s', 's__supported_units', 'supportedUnits'); |
| 168 | + $resultSet = [ |
| 169 | + [ |
| 170 | + 's__id' => 1, |
| 171 | + 's__supported_units' => 'g,m,unknown_case', |
| 172 | + ], |
| 173 | + ]; |
| 174 | + |
| 175 | + $stmt = ArrayResultFactory::createFromArray($resultSet); |
| 176 | + $hydrator = new SimpleObjectHydrator($this->entityManager); |
| 177 | + $hydrator->hydrateAll($stmt, $rsm); |
| 178 | + } |
158 | 179 | }
|
0 commit comments