/** * @test */ public function hydrate_contact_with_link_list() { $md = $this->manager->getClassMetadata(Stub\Linked\Contact::class); $dh = new DynamicHydrator($this->manager, $this->manager->getUnitOfWork(), $md); $c = new Stub\Linked\Contact(); $d = json_decode(<<<JSON { "@rid": "#1:1", "name": "Sydney", "phones": [ "#3:1", "#3:2" ] } JSON , true); $hd = $dh->hydrate($c, $d); $this->assertEquals(['rid', 'name', 'phones'], array_keys($hd)); $this->assertEquals('#1:1', $hd['rid']); $this->assertEquals('Sydney', $hd['name']); /** @var Stub\Linked\Phone[] $phones */ $phones = $c->getPhones()->toArray(); $this->assertCount(2, $phones); $phone = $phones[0]; $this->assertEquals('work', $phone->type); $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->uow->getDocumentState($phone)); $this->assertTrue($this->uow->isInIdentityMap($phone)); $phone = $phones[1]; $this->assertEquals('home', $phone->type); $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->uow->getDocumentState($phone)); $this->assertTrue($this->uow->isInIdentityMap($phone)); }