Skip to content

Commit a405d4f

Browse files
wip
1 parent 69b91e9 commit a405d4f

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [8.1, 8.2, 8.3]
15-
laravel: [10.*, 11.*]
14+
php: [8.1, 8.2, 8.3, 8.4]
15+
laravel: [10.*, 11.*, 12.*]
1616
dependency-version: [prefer-lowest, prefer-stable]
1717
exclude:
1818
- php: 8.1
1919
laravel: 11.*
20+
- php: 8.1
21+
laravel: 12.*
2022

2123
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2224

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ composer.phar
33
composer.lock
44
vendor
55
.php_cs.cache
6-
.phpunit.result.cache
6+
.phpunit.result.cache
7+
.phpunit.cache
8+
.claude

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
}
88
},
99
"require": {
10-
"php": "^8.1",
11-
"illuminate/container": "^10.0|^11.0",
12-
"illuminate/database": "^10.0|^11.0",
13-
"illuminate/support": "^10.0|^11.0",
10+
"php": "^8.1|^8.2|^8.3|^8.4",
11+
"illuminate/container": "^10.0|^11.0|^12.0",
12+
"illuminate/database": "^10.0|^11.0|^12.0",
13+
"illuminate/support": "^10.0|^11.0|^12.0",
1414
"spatie/laravel-query-builder": "^5.0"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^9.0",
18-
"laravel/laravel": "^10.0|^11.0",
17+
"phpunit/phpunit": "^10.0|^11.0",
18+
"laravel/laravel": "^10.0|^11.0|^12.0",
1919
"mockery/mockery": "^1.5",
2020
"makeabledk/laravel-factory-enhanced": "^5.0",
2121
"fakerphp/faker": "^1.18"

phpunit.xml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
verbose="true"
12-
>
13-
<testsuites>
14-
<testsuite name="Package Test Suite">
15-
<directory suffix="Test.php">./tests/</directory>
16-
</testsuite>
17-
</testsuites>
18-
<php>
19-
<ini name="display_errors" value="1" />
20-
<server name="APP_ENV" value="testing" />
21-
<server name="APP_DEBUG" value="true" />
22-
<server name="DB_CONNECTION" value="sqlite" />
23-
<server name="DB_DATABASE" value=":memory:" />
24-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Package Test Suite">
5+
<directory suffix="Test.php">./tests/</directory>
6+
</testsuite>
7+
</testsuites>
8+
<php>
9+
<ini name="display_errors" value="1"/>
10+
<server name="APP_ENV" value="testing"/>
11+
<server name="APP_DEBUG" value="true"/>
12+
<server name="DB_CONNECTION" value="sqlite"/>
13+
<server name="DB_DATABASE" value=":memory:"/>
14+
</php>
2515
</phpunit>

tests/Feature/EndpointHttpTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,27 @@ public function it_supports_circular_includes()
132132
]],
133133
]]);
134134
}
135+
136+
/** @test **/
137+
public function it_supports_allowed_includes_syntax()
138+
{
139+
140+
$server = factory(User::class)
141+
->with(1, 'teams')
142+
->create();
143+
144+
$this
145+
->withoutExceptionHandling()
146+
->getJson('/servers?include=databases.server&append=databases.server.internal_ip')
147+
->assertSuccessful()
148+
->assertJson([[
149+
'id' => $server->id,
150+
'databases' => [[
151+
'server' => [
152+
'id' => $server->id,
153+
'internal_ip' => '127.0.0.1',
154+
],
155+
]],
156+
]]);
157+
}
135158
}

tests/Stubs/Endpoints/UserEndpoint.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Makeable\ApiEndpoints\Endpoint;
66
use Makeable\ApiEndpoints\Tests\Stubs\User;
7+
use Spatie\QueryBuilder\AllowedInclude;
78

89
class UserEndpoint extends Endpoint
910
{
@@ -14,7 +15,9 @@ public function __invoke()
1415
$this
1516
->allowedIncludes([
1617
'servers' => ServerEndpoint::make(),
18+
// 'serversCount' => AllowedInclude::count('servers'),
1719
'favoriteServers' => ServerEndpoint::make(),
20+
AllowedInclude::relationship('teams'),
1821
]);
1922
}
2023
}

0 commit comments

Comments
 (0)