Skip to content

Commit

Permalink
Merge branch '1.x' of github.com:inertiajs/inertia-laravel into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Dec 5, 2024
2 parents f6bd63a + f6d3e16 commit 7e6a030
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public function toResponse($request)
'props' => $props,
'url' => Str::start(Str::after($request->fullUrl(), $request->getSchemeAndHttpHost()), '/'),
'version' => $this->version,
'encryptHistory' => false,
'clearHistory' => false,
];

if ($request->header(Header::INERTIA)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function share($key, $value = null): void
}
}

public function getShared(string $key = null, $default = null)
public function getShared(?string $key = null, $default = null)
{
if ($key) {
return Arr::get($this->sharedProps, $key, $default);
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/AssertableInertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function fromTestResponse(TestResponse $response): self
return $instance;
}

public function component(string $value = null, $shouldExist = null): self
public function component(?string $value = null, $shouldExist = null): self
{
PHPUnit::assertSame($value, $this->component, 'Unexpected Inertia page component.');

Expand Down
6 changes: 3 additions & 3 deletions src/Testing/Concerns/Debugging.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

trait Debugging
{
public function dump(string $prop = null): self
public function dump(?string $prop = null): self
{
dump($this->prop($prop));

return $this;
}

public function dd(string $prop = null): void
public function dd(?string $prop = null): void
{
dd($this->prop($prop));
}

abstract protected function prop(string $key = null);
abstract protected function prop(?string $key = null);
}
4 changes: 2 additions & 2 deletions src/Testing/Concerns/Has.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function hasAll($key): self
/**
* @return $this
*/
public function has(string $key, $value = null, Closure $scope = null): self
public function has(string $key, $value = null, ?Closure $scope = null): self
{
PHPUnit::assertTrue(
Arr::has($this->prop(), $key),
Expand Down Expand Up @@ -106,7 +106,7 @@ public function misses(string $key): self
return $this->missing($key);
}

abstract protected function prop(string $key = null);
abstract protected function prop(?string $key = null);

abstract protected function dotPath(string $key): string;

Expand Down
2 changes: 1 addition & 1 deletion src/Testing/Concerns/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public function etc(): self
return $this;
}

abstract protected function prop(string $key = null);
abstract protected function prop(?string $key = null);
}
4 changes: 2 additions & 2 deletions src/Testing/Concerns/Matching.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function ensureSorted(&$value): void

abstract protected function dotPath(string $key): string;

abstract protected function prop(string $key = null);
abstract protected function prop(?string $key = null);

abstract public function has(string $key, $value = null, Closure $scope = null);
abstract public function has(string $key, $value = null, ?Closure $scope = null);
}
4 changes: 2 additions & 2 deletions src/Testing/Concerns/PageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait PageObject
{
public function component(string $value = null, $shouldExist = null): self
public function component(?string $value = null, $shouldExist = null): self
{
PHPUnit::assertSame($value, $this->component, 'Unexpected Inertia page component.');

Expand All @@ -23,7 +23,7 @@ public function component(string $value = null, $shouldExist = null): self
return $this;
}

protected function prop(string $key = null)
protected function prop(?string $key = null)
{
return Arr::get($this->props, $key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/TestResponseMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestResponseMacros
{
public function assertInertia()
{
return function (Closure $callback = null) {
return function (?Closure $callback = null) {
$assert = AssertableInertia::fromTestResponse($this);

if (is_null($callback)) {
Expand Down
2 changes: 2 additions & 0 deletions tests/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function test_controller_returns_an_inertia_response(): void
],
'url' => '/',
'version' => '',
'encryptHistory' => false,
'clearHistory' => false,
]);
}
}
5 changes: 2 additions & 3 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function test_server_response(): void
$this->assertSame('Jonathan', $page['props']['user']['name']);
$this->assertSame('/user/123', $page['url']);
$this->assertSame('123', $page['version']);
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;}"></div>', $view->render());
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;,&quot;encryptHistory&quot;:false,&quot;clearHistory&quot;:false}"></div>', $view->render());
}

public function test_xhr_response(): void
Expand Down Expand Up @@ -98,8 +98,7 @@ public function test_lazy_resource_response(): void
$callable = static function () use ($users) {
$page = new LengthAwarePaginator($users->take(2), $users->count(), 2);

return new class($page, JsonResource::class) extends ResourceCollection {
};
return new class($page, JsonResource::class) extends ResourceCollection {};
};

$response = new Response('User/Index', ['users' => $callable], 'app', '123');
Expand Down

0 comments on commit 7e6a030

Please sign in to comment.