Mod setArray macro for nested values

This commit is contained in:
philipp lang 2024-10-24 22:39:45 +02:00
parent 396563e6e1
commit 092227d1e8
1 changed files with 10 additions and 3 deletions

View File

@ -174,11 +174,18 @@ class TestCase extends BaseTestCase
return $this;
});
Testable::macro('setArray', function ($attributes) {
Testable::macro('setArray', function ($attributes, $value = null) {
$self = $this;
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;
});