Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
21ed435
Add CI improvements
claudiodekker Aug 20, 2020
b0302c1
Update .gitattributes
claudiodekker Aug 21, 2020
0f15c23
Merge branch 'master' into ci-improvements
claudiodekker Sep 30, 2020
d0ebaa6
Disable branch limiter for now
claudiodekker Sep 30, 2020
1ec5f01
Remove PHP <= 5.5, add PHP 8.0
claudiodekker Sep 30, 2020
14ca6d6
Update testbench dependency for Laravel 6, 7, 8
claudiodekker Sep 30, 2020
34c3f8b
Drop Laravel <= 6.0 (TestBench issues)
claudiodekker Sep 30, 2020
3b5e25f
Remove TravisCI testing for PHP <= 7.1
claudiodekker Sep 30, 2020
b1c92f2
Remove TravisCI config warnings
claudiodekker Sep 30, 2020
dded5a2
Merge branch 'laravel-5.4-auto-middleware-registration' into ci-impro…
claudiodekker Sep 30, 2020
f11a8c4
Merge branch 'master' into ci-improvements
claudiodekker Sep 30, 2020
22dcce9
Fix: TestResponse not found on Laravel 6+
claudiodekker Sep 30, 2020
864a83a
Fix @covers annotation issue
claudiodekker Sep 30, 2020
e4eff76
Fix PHPUnit issues in earlier Laravel releases
claudiodekker Sep 30, 2020
4bc90d7
Remove PHP 8.0 from Travis (not yet supported)
claudiodekker Sep 30, 2020
065e628
Fix failing test
claudiodekker Sep 30, 2020
f79efb1
Apply fixes from StyleCI
claudiodekker Sep 30, 2020
2b13249
Merge pull request #2 from claudiodekker/analysis-Px9YO9
claudiodekker Sep 30, 2020
f6cbb11
Lower minimal version to Laravel 6.10
claudiodekker Sep 30, 2020
b34ddf5
Merge branch 'ci-improvements' of github-as-personal:claudiodekker/in…
claudiodekker Sep 30, 2020
19f86a6
Switch to Github Actions
claudiodekker Oct 3, 2020
bbc7bcd
Fix identation
claudiodekker Oct 3, 2020
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
/tests export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor
.DS_Store
.php_cs
.php_cs.cache
.phpunit.result.cache
composer.lock
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: laravel
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
os: linux
dist: xenial
language: php

php:
- 7.2
- 7.3
- 7.4

env:
jobs:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update --prefer-source $COMPOSER_FLAGS

script:
- phpunit

#branches:
# only:
# - master
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
}
},
"require": {
"laravel/framework": "^5.4|^6.0|^7.0|^8.0"
"laravel/framework": "^6.12|^7.0|^8.0"
},
"require-dev": {
"orchestra/testbench": "~3.0"
"ext-json": "*",
"orchestra/testbench": "^4.0|^5.0|^6.0"
},
"extra": {
"laravel": {
Expand Down
2 changes: 1 addition & 1 deletion helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!function_exists('inertia')) {
if (! function_exists('inertia')) {
/**
* Inertia helper.
*
Expand Down
26 changes: 14 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd"
bootstrap="vendor/autoload.php"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function handle($request, Closure $next)
{
$response = $next($request);

if (!$request->header('X-Inertia')) {
if (! $request->header('X-Inertia')) {
return $response;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Inertia;

use Closure;
use Illuminate\Support\Arr;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\App;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Response as ResponseFactory;

class Response implements Responsable
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Inertia;

use Closure;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;

class ResponseFactory
{
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Inertia;

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;
Expand Down
4 changes: 2 additions & 2 deletions tests/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Inertia\Tests;

use Inertia\Response;
use Inertia\Controller;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Inertia\Controller;
use Inertia\Response;

class ControllerTest extends TestCase
{
Expand Down
8 changes: 7 additions & 1 deletion tests/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Inertia\Tests;

use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
use Illuminate\Http\Request;
use Illuminate\Testing\TestResponse;
use Inertia\Inertia;
use Inertia\Middleware;

Expand Down Expand Up @@ -85,6 +86,11 @@ private function makeMockResponse($request)
return Inertia::render('User/Edit', ['user' => ['name' => 'Jonathan']])->toResponse($request);
});

// Laravel <= 6.0
if (class_exists(LegacyTestResponse::class)) {
return LegacyTestResponse::fromBaseResponse($response);
}

return TestResponse::fromBaseResponse($response);
}
}
31 changes: 21 additions & 10 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

namespace Inertia\Tests;

use Arr;
use Illuminate\Contracts\Support\Arrayable;
use Inertia\Response;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Fluent;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Illuminate\Http\Response as BaseResponse;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Http\Response as BaseResponse;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Fluent;
use Illuminate\View\View;
use Inertia\Response;

class ResponseTest extends TestCase
{
Expand Down Expand Up @@ -103,7 +104,7 @@ public function test_lazy_resource_response()
$page = $response->getData();

$expected = [
'data' => $users->take(2),
'data' => $users->take(2)->toArray(),
'links' => [
'first' => '/?page=1',
'last' => '/?page=2',
Expand All @@ -123,9 +124,20 @@ public function test_lazy_resource_response()

$this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('User/Index', $page->component);
$this->assertSame(json_encode($expected), json_encode($page->props->users));
$this->assertSame('/users?page=1', $page->url);
$this->assertSame('123', $page->version);

tap(json_decode(json_encode($page->props->users), true), function ($actual) use ($expected) {
// On Laravel 8+, new 'links' were added to the 'meta' section for convenience.
// We'll just inject these to our expected array to prevent testing issues
// on earlier version of Laravel.
if (Arr::has($actual, 'meta.links')) {
$expected['meta']['links'] = $actual['meta']['links'];
ksort($expected['meta']);
}

$this->assertSame($expected, $actual);
});
}

public function test_arrayable_prop_response()
Expand All @@ -136,7 +148,6 @@ public function test_arrayable_prop_response()
$user = (object) ['name' => 'Jonathan'];

$resource = new class($user) implements Arrayable {

public $user;

public function __construct($user)
Expand Down
9 changes: 4 additions & 5 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
namespace Inertia\Tests;

use Closure;
use Inertia\Inertia;
use Inertia\Middleware;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\App;
use Illuminate\Support\ViewErrorBag;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\MessageBag;
use Illuminate\Support\ViewErrorBag;
use Inertia\Inertia;
use Inertia\Middleware;

class ServiceProviderTest extends TestCase
{
Expand Down