Skip to content

Commit 478c25e

Browse files
Add tests
1 parent 168cf9b commit 478c25e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/EmbeddedRelationsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,4 +972,18 @@ public function testUnsetPropertyOnEmbed()
972972
$this->assertNull($user->addresses->get(0)->city);
973973
$this->assertSame('Kyoto', $user->addresses->get(1)->city);
974974
}
975+
976+
public function testEmbedManyToArrayCast()
977+
{
978+
$user = User::create(['name' => 'John Doe']);
979+
$user->addresses()->saveMany([new Address(['city' => 'London'])]);
980+
981+
//Reload document
982+
$user = User::where('name', 'John Doe')->first();
983+
$array = $user->toArray();
984+
985+
$this->assertIsString($array['addresses'][0]['id']);
986+
$this->assertIsString($array['addresses'][0]['created_at']);
987+
$this->assertIsString($array['addresses'][0]['updated_at']);
988+
}
975989
}

0 commit comments

Comments
 (0)