From 092227d1e8a2cabd495e3462319a265ddbdf0711 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 24 Oct 2024 22:39:45 +0200 Subject: [PATCH] Mod setArray macro for nested values --- tests/TestCase.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 44acf046..f498bb39 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -174,10 +174,17 @@ class TestCase extends BaseTestCase return $this; }); - Testable::macro('setArray', function ($attributes) { + Testable::macro('setArray', function ($attributes, $value = null) { $self = $this; - foreach ($attributes as $key => $value) { - $self = $this->set($key, $value); + if ($value === null) { + foreach ($attributes as $key => $value) { + $self = $this->set($key, $value); + } + return $self; + } + + foreach ($value as $key => $v) { + $self = $self->set($attributes . '.' . $key, $v); } return $self;