Skip to content

Commit a43d67f

Browse files
committed
Minor cleanup
1 parent 2c1e52f commit a43d67f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Testing/TestResponseMacros.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ public function inertiaPage()
3232
public function inertiaProps()
3333
{
3434
return function (?string $propName = null) {
35-
return Arr::get(
36-
$this->inertiaPage()['props'] ?? [],
37-
$propName
38-
);
35+
return Arr::get($this->inertiaPage()['props'], $propName);
3936
};
4037
}
4138
}

tests/Testing/TestResponseMacrosTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,22 @@ public function test_it_can_retrieve_the_inertia_props(): void
5858
Inertia::render('foo', $props)
5959
);
6060

61-
tap($response->inertiaProps(), fn (array $pageProps) => $this->assertSame($props, $pageProps));
61+
$this->assertSame($props, $response->inertiaProps());
6262
}
6363

6464
public function test_it_can_retrieve_nested_inertia_prop_values_with_dot_notation(): void
6565
{
6666
$response = $this->makeMockRequest(
67-
Inertia::render('foo', ['bar' => ['baz' => 'qux']])
67+
Inertia::render('foo', [
68+
'bar' => ['baz' => 'qux'],
69+
'users' => [
70+
['name' => 'John'],
71+
['name' => 'Jane'],
72+
],
73+
])
6874
);
6975

70-
tap($response->inertiaProps('bar.baz'), fn (mixed $value) => $this->assertSame('qux', $value));
76+
$this->assertSame('qux', $response->inertiaProps('bar.baz'));
77+
$this->assertSame('John', $response->inertiaProps('users.0.name'));
7178
}
7279
}

0 commit comments

Comments
 (0)