From 2409fe3a0382777d5a3373cb7802acabcaa2ff23 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Thu, 9 Mar 2023 11:24:57 +0300 Subject: [PATCH] [10.x] Add test for dot method in collections --- tests/Support/SupportCollectionTest.php | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 01b49c93afd3..a5e1863c0dda 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -5531,6 +5531,42 @@ public function testUndot($collection) ], $data->all()); } + /** + * @dataProvider collectionClassProvider + */ + public function testDot($collection) + { + $data = $collection::make([ + 'name' => 'Taylor', + 'meta' => [ + 'foo' => 'bar', + 'baz' => 'boom', + 'bam' => [ + 'boom' => 'bip', + ], + ], + ])->dot(); + $this->assertSame([ + 'name' => 'Taylor', + 'meta.foo' => 'bar', + 'meta.baz' => 'boom', + 'meta.bam.boom' => 'bip', + ], $data->all()); + + $data = $collection::make([ + 'foo' => [ + 'bar', + 'baz', + 'baz' => 'boom', + ], + ])->dot(); + $this->assertSame([ + 'foo.0' => 'bar', + 'foo.1' => 'baz', + 'foo.baz' => 'boom', + ], $data->all()); + } + /** * Provides each collection class, respectively. *