|
8 | 8 | use Doctrine\ORM\Mapping\AssociationMapping; |
9 | 9 | use Doctrine\ORM\Mapping\ClassMetadata; |
10 | 10 | use Doctrine\ORM\Query; |
| 11 | +use Doctrine\Tests\Models\Hydration\EntityWithArrayDefaultArrayValueM2M; |
| 12 | +use Doctrine\Tests\Models\Hydration\SimpleEntity; |
11 | 13 |
|
12 | 14 | use Doctrine\Tests\Models\CMS\CmsUser; |
13 | 15 |
|
@@ -1956,4 +1958,29 @@ public function testInvalidDiscriminatorValueException() |
1956 | 1958 | $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); |
1957 | 1959 | $hydrator->hydrateAll($stmt, $rsm); |
1958 | 1960 | } |
| 1961 | + |
| 1962 | + public function testFetchJoinCollectionValuedAssociationWithDefaultArrayValue() |
| 1963 | + { |
| 1964 | + $rsm = new ResultSetMapping; |
| 1965 | + |
| 1966 | + $rsm->addEntityResult(EntityWithArrayDefaultArrayValueM2M::CLASSNAME, 'e1', null); |
| 1967 | + $rsm->addJoinedEntityResult(SimpleEntity::CLASSNAME, 'e2', 'e1', 'collection'); |
| 1968 | + $rsm->addFieldResult('e1', 'a1__id', 'id'); |
| 1969 | + $rsm->addFieldResult('e2', 'e2__id', 'id'); |
| 1970 | + |
| 1971 | + $result = (new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em)) |
| 1972 | + ->hydrateAll( |
| 1973 | + new HydratorMockStatement([[ |
| 1974 | + 'a1__id' => '1', |
| 1975 | + 'e2__id' => '1', |
| 1976 | + ]]), |
| 1977 | + $rsm |
| 1978 | + ); |
| 1979 | + |
| 1980 | + $this->assertCount(1, $result); |
| 1981 | + $this->assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::CLASSNAME, $result[0]); |
| 1982 | + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->collection); |
| 1983 | + $this->assertCount(1, $result[0]->collection); |
| 1984 | + $this->assertInstanceOf(SimpleEntity::CLASSNAME, $result[0]->collection[0]); |
| 1985 | + } |
1959 | 1986 | } |
0 commit comments