8000 Merge branch 'feature/laravel-5.5' into develop · tooshay/laravel-json-api@c270eea · GitHub
[go: up one dir, main page]

10000
Skip to content

Commit c270eea

Browse files
committed
Merge branch 'feature/laravel-5.5' into develop
2 parents 1c8f696 + 338c046 commit c270eea

File tree

7 files changed

+84
-26
lines changed

7 files changed

+84
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. This projec
55
## Unreleased
66

77
### Added
8+
- Support for Laravel 5.5.
89
- Client supplied ids will now be hydrated into Eloquent models, configurable via the `$clientId` property
910
on the Eloquent hydrator.
1011

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ A demo application is available at [here](https://github.com/cloudcreativity/dem
2525

2626
## Laravel Versions
2727

28-
We use semantic versioning but Laravel does not. This table will help...
29-
3028
| Laravel | This Package |
3129
| --- | --- |
32-
| 5.3.* | ^0.9 |
33-
| 5.4.* | ^0.10 |
30+
| 5.4.* | ^0.11 |
31+
| 5.5.* | ^0.11 |
3432

3533
Make sure you consult the [Upgrade Guide](http://laravel-json-api.readthedocs.io/en/latest/upgrade/) when upgrading.
3634

@@ -57,7 +55,7 @@ Apache License (Version 2.0). Please see [License File](LICENSE) for more inform
5755

5856
## Installation
5957

60-
Installation is via `composer`. See the wiki for complete instructions.
58+
Installation is via `composer`. See the documentation for complete instructions.
6159

6260
## Contributing
6361

composer.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@
2424
"require": {
2525
"php": "^5.6|^7.0",
2626
"cloudcreativity/json-api": "^0.11",
27-
"illuminate/console": "5.4.*",
28-
"illuminate/contracts": "5.4.*",
29-
"illuminate/database": "5.4.*",
30-
"illuminate/filesystem": "5.4.*",
31-
"illuminate/http": "5.4.*",
32-
"illuminate/pagination": "5.4.*",
33-
"illuminate/support": "5.4.*",
27+
"illuminate/console": "5.4.*|5.5.*",
28+
"illuminate/contracts": "5.4.*|5.5.*",
29+
"illuminate/database": "5.4.*|5.5.*",
30+
"illuminate/filesystem": "5.4.*|5.5.*",
31+
"illuminate/http": "5.4.*|5.5.*",
32+
"illuminate/pagination": "5.4.*|5.5.*",
33+
"illuminate/support": "5.4.*|5.5.*",
3434
"symfony/psr-http-message-bridge": "^1.0",
3535
"zendframework/zend-diactoros": "^1.3"
3636
},
3737
"require-dev": {
3838
"ext-sqlite3": "*",
39-
"cloudcreativity/json-api-testing": "^0.1.1",
40-
"illuminate/routing": "5.4.*",
41-
"orchestra/testbench": "~3.0",
42-
"phpunit/phpunit": "^5.7"
39+
"cloudcreativity/json-api-testing": "^0.1.1|^0.2",
40+
"orchestra/testbench": "^3.4",
41+
"phpunit/phpunit": "^5.7|^6.0"
4342
},
4443
"suggest": {
4544
"cloudcreativity/json-api-testing": "Required to use the test helpers."
@@ -60,9 +59,17 @@
6059
"extra": {
6160
"branch-alias": {
6261
"dev-develop": "0.11.x-dev"
62+
},
63+
"laravel": {
64+
"providers": [
65+
"CloudCreativity\\LaravelJsonApi\\ServiceProvider"
66+
],
67+
"aliases": {
68+
"JsonApi": "CloudCreativity\\LaravelJsonApi\\Facades\\JsonApi"
69+
}
6370
}
6471
},
65-
"minimum-stability": "dev",
72+
"minimum-stability": "stable",
6673
"prefer-stable": true,
6774
"config": {
6875
"sort-packages": true

docs/installation.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
# Installation
22

3+
## Laravel 5.5
4+
5+
Install using [Composer](http://getcomposer.org):
6+
7+
``` bash
8+
$ composer require cloudcreativity/laravel-json-api
9+
$ composer require --dev cloucdreativity/json-api-testing
10+
```
11+
12+
This package's service provider and facade will be automatically added using package discovery. You will
13+
need to follow the instructions below for updating your `ExceptionHandler`.
14+
15+
## Laravel 5.4
16+
317
Install using [Composer](http://getcomposer.org):
418

519
``` bash
620
$ composer require cloudcreativity/laravel-json-api
21+
$ composer require --dev cloucdreativity/json-api-testing
722
```
823

924
Add the package service provider to your `config/app.php` providers array.
@@ -25,8 +40,6 @@ If you would like to use the `JsonApi` facade, add the following to the list of
2540
]
2641
```
2742

28-
> The `JsonApi` facade maps to the `CloudCreativity\LaravelJsonApi\Services\JsonApiService` class.
29-
3043
## Exception Handling
3144

3245
Parts of the package throw exceptions to abort execution and render JSON API errors. Your will therefore need to

docs/upgrade.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,38 @@ As we are currently on pre-1.0 releases, when you upgrade you will also need to
44
dependencies need to be upgraded. Use the following command:
55

66
```bash
7-
$ composer require cloudcreativity/laravel-json-api:^0.10 --update-with-dependencies
7+
$ composer require cloudcreativity/laravel-json-api:^0.11 --update-with-dependencies
88
```
99

10+
## Upgrading to 0.11 from 0.10
11+
12+
Version `0.11` now supports Laravel 5.5 in addition to 5.4.
13+
14+
### Package Discovery
15+
16+
If you are on Laravel 5.5, you no longer need to add the service provider and facade to your `app.php` config as
17+
we have added package discovery configuration. Feel free to remove the service provider and facade from your
18+
config file.
19+
20+
### Testing
21+
22+
The test helper classes have been extracted to a separate package to allow us to support both PHPUnit 5.7 and 6.
23+
The new package can be installed using composer:
24+
25+
```bash
26+
$ composer require --dev cloudcreativity/json-api-testing
27+
```
28+
29+
We have removed all test helper methods on the `TestResponse` class that were marked as deprecated in `0.10`.
30+
You will need to update your tests if you have not already done so:
31+
32+
- `seeStatusCode()`: use `assertStatus()`
33+
- `seeDataCollection()`: use `assertDataCollection()`
34+
- `seeDataResource()`: use `assertDataResource()`
35+
- `seeDataResourceIdentifier()`: use `assertDataResourceIdentifier()`
36+
- `seeDocument()`: use `assertDocument()`
37+
- `seeErrors()`: use `assertErrors()`
38+
1039
## Upgrading to 0.10 from 0.9
1140

1241
### Facade

src/Console/Commands/AbstractGeneratorCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ public function __construct(Filesystem $files, Repository $apiRepository)
9191
/**
9292
* @return bool|null
9393
*/
94-
public function fire()
94+
public function handle()
9595
{
9696
if (!$this->apiRepository->exists($api = $this->argument('api'))) {
9797
$this->error("JSON API '$api' does not exist.");
9898
return 1;
9999
}
100100

101-
return (parent::fire() !== false) ? 0 : 1;
101+
/** @todo remove when removing support for Laravel 5.4 */
102+
if (is_callable(['parent', 'fire'])) {
103+
return (parent::fire() !== false) ? 0 : 1;
104+
}
105+
106+
return (parent::handle() !== false) ? 0 : 1;
102107
}
103108

104109
/**

src/Testing/InteractsWithModels.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Illuminate\Database\Eloquent\Model;
2222
use Illuminate\Foundation\Testing\Constraints\HasInDatabase;
2323
use Illuminate\Foundation\Testing\Constraints\SoftDeletedInDatabase;
24-
use PHPUnit_Framework_Constraint_Not as ReverseConstraint;
24+
use PHPUnit\Framework\Constraint\LogicalNot;
2525

2626
/**
2727
* Class InteractsWithModels
@@ -152,12 +152,17 @@ protected function assertDatabaseHasModel(Model $model, array $data)
152152
* @param Model $model
153153
* @param array $data
154154
* @return $this
155+
* @todo update method when dropping support for Laravel 5.4
155156
*/
156157
protected function assertDatabaseMissingModel(Model $model, array $data)
157158
{
158-
$constraint = new ReverseConstraint(
159-
new HasInDatabase($model->getConnection(), $data)
160-
);
159+
if (class_exists('PHPUnit_Framework_Constraint_Not')) {
160+
$constraint = new \PHPUnit_Framework_Constraint_Not(
161+
new HasInDatabase($model->getConnection(), $data)
162+
);
163+
} else {
164+
$constraint = new LogicalNot(new HasInDatabase($model->getConnection(), $data));
165+
}
161166

162167
$this->assertThat($model->getTable(), $constraint);
163168

0 commit comments

Comments
 (0)
0