Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 15 additions & 16 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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' => '[email protected]',
Expand Down Expand Up @@ -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' => '[email protected]',
Expand Down Expand Up @@ -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';
});

Expand All @@ -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';
});

Expand Down Expand Up @@ -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' => '[email protected]',
Expand Down Expand Up @@ -859,13 +858,13 @@ public function test_inertia_responsable_objects(): void
new class implements ProvidesInertiaProperties
{
/**
* @return \Illuminate\Support\Collection<string, string>
* @return array<string, mixed>
*/
public function toInertiaProperties(RenderContext $context): iterable
{
return collect([
return [
'baz' => 'qux',
]);
];
}
},
'quux' => 'corge',
Expand Down Expand Up @@ -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<string, string>
* @return array<string, mixed>
*/
public function toInertiaProperties(RenderContext $context): iterable
{
return collect(['grault' => 'garply']);
return ['grault' => 'garply'];
}
});

Expand Down