diff --git a/helpers.php b/helpers.php index 012f001f..d37f6931 100644 --- a/helpers.php +++ b/helpers.php @@ -24,7 +24,7 @@ function inertia($component = null, $props = []) /** * Inertia location helper. * - * @param string url + * @param string $url * @return \Symfony\Component\HttpFoundation\Response */ function inertia_location($url) diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index b5a78722..f9e52901 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -14,14 +14,13 @@ use Inertia\AlwaysProp; use Inertia\DeferProp; use Inertia\Inertia; -use Inertia\LazyProp; use Inertia\MergeProp; +use Inertia\OptionalProp; use Inertia\ProvidesInertiaProperties; use Inertia\RenderContext; use Inertia\Response; use Inertia\Tests\Stubs\FakeResource; use Inertia\Tests\Stubs\MergeWithSharedProp; -use Mockery; class ResponseTest extends TestCase { @@ -619,10 +618,10 @@ public function test_promise_props_are_resolved(): void $user = (object) ['name' => 'Jonathan']; - $promise = Mockery::mock('GuzzleHttp\Promise\PromiseInterface') - ->shouldReceive('wait') - ->andReturn($user) - ->getMock(); + $promise = $this->mock('GuzzleHttp\Promise\PromiseInterface', function ($mock) use ($user) { + $mock->shouldReceive('wait') + ->andReturn($user); + }); $response = new Response('User/Edit', ['user' => $promise], 'app', '123'); /** @var JsonResponse $response */ @@ -693,7 +692,7 @@ public function test_nested_partial_props(): void $props = [ 'auth' => [ - 'user' => new LazyProp(function () { + 'user' => new OptionalProp(function () { return [ 'name' => 'Jonathan Reinink', 'email' => 'jonathan@example.com', @@ -729,7 +728,7 @@ public function test_exclude_nested_props_from_partial_response(): void $props = [ 'auth' => [ - 'user' => new LazyProp(function () { + 'user' => new OptionalProp(function () { return [ 'name' => 'Jonathan Reinink', 'email' => 'jonathan@example.com', @@ -757,7 +756,7 @@ public function test_lazy_props_are_not_included_by_default(): void $request = Request::create('/users', 'GET'); $request->headers->add(['X-Inertia' => 'true']); - $lazyProp = new LazyProp(function () { + $lazyProp = new OptionalProp(function () { return 'A lazy value'; }); @@ -777,7 +776,7 @@ public function test_lazy_props_are_included_in_partial_reload(): void $request->headers->add(['X-Inertia-Partial-Component' => 'Users']); $request->headers->add(['X-Inertia-Partial-Data' => 'lazy']); - $lazyProp = new LazyProp(function () { + $lazyProp = new OptionalProp(function () { return 'A lazy value'; }); @@ -824,7 +823,7 @@ public function test_always_props_are_included_on_partial_reload(): void $request->headers->add(['X-Inertia-Partial-Data' => 'data']); $props = [ - 'user' => new LazyProp(function () { + 'user' => new OptionalProp(function () { return [ 'name' => 'Jonathan Reinink', 'email' => 'jonathan@example.com', @@ -859,13 +858,13 @@ public function test_inertia_responsable_objects(): void new class implements ProvidesInertiaProperties { /** - * @return \Illuminate\Support\Collection + * @return array */ public function toInertiaProperties(RenderContext $context): iterable { - return collect([ + return [ 'baz' => 'qux', - ]); + ]; } }, 'quux' => 'corge', @@ -971,11 +970,11 @@ public function test_props_can_be_added_using_the_with_method(): void ->with(new class implements ProvidesInertiaProperties { /** - * @return \Illuminate\Support\Collection + * @return array */ public function toInertiaProperties(RenderContext $context): iterable { - return collect(['grault' => 'garply']); + return ['grault' => 'garply']; } });