Skip to content

Commit 6c87df8

Browse files
committed
Update tests, update CHANGELOG
1 parent 09040d1 commit 6c87df8

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [Unreleased]
7+
8+
### Added
9+
10+
- New method `Utils\Helper::parseResponseBody()` to parse a JSON API response body
11+
- New method `Utils\Helper::isValidResponseBody()` to validate a JSON API response body
12+
- New method `Utils\Helper::isValidRequestBody()` to validate a JSON API request body with optional item id
13+
14+
### Deprecated
15+
16+
- `Utils\Helper::parse()` will be removed in v1.0, use `Utils\Helper::parseResponseBody()` instead
17+
- `Utils\Helper::isValid()` will be removed in v1.0, use `Utils\Helper::isValidResponseBody()` instead
18+
619
## [0.8.1] - 2017-06-01
720

821
### Fixed

composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
"type": "library",
44
"description": "JSON API client",
55
"homepage": "https://github.com/Art4/json-api-client",
6-
"keywords": ["json", "api", "json-api", "client", "reader", "validator"],
7-
"license": "GPL2",
6+
"keywords": ["json", "api", "json-api", "client", "reader", "validator", "parser"],
7+
"license": "GPL3",
88
"authors": [
99
{
1010
"name": "Artur Weigandt",
1111
"email": "art4@wlabs.de",
12-
"homepage": "http://wlabs.de"
12+
"homepage": "https://wlabs.de"
1313
}
1414
],
1515
"require": {
1616
"php": "^5.5 || ^7.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.8.35 || ^6.0"
19+
"phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -27,5 +27,11 @@
2727
"psr-4": {
2828
"Art4\\JsonApiClient\\Tests\\": "tests"
2929
}
30+
},
31+
"config": {
32+
"//platform": {
33+
"php": "5.5"
34+
},
35+
"sort-packages": true
3036
}
3137
}

tests/Integration/DotNotationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DotNotationTest extends \Art4\JsonApiClient\Tests\Fixtures\TestCase
3232
public function testCompleteResourceObjectWithMultipleRelationships()
3333
{
3434
$string = $this->getJsonString('04_complete_document_with_multiple_relationships.json');
35-
$document = Helper::parse($string);
35+
$document = Helper::parseResponseBody($string);
3636

3737
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
3838

@@ -197,7 +197,7 @@ public function testCompleteResourceObjectWithMultipleRelationships()
197197
public function testGetNotExistentValueThrowsException()
198198
{
199199
$string = $this->getJsonString('05_simple_meta_object.json');
200-
$document = Helper::parse($string);
200+
$document = Helper::parseResponseBody($string);
201201

202202
// Test 3 segments, segment 2 don't exists
203203
$this->assertFalse($document->has('meta.foobar.zap'));

tests/Integration/ErrorParsingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ErrorParsingTest extends \Art4\JsonApiClient\Tests\Fixtures\TestCase
3232
public function testParseErrors()
3333
{
3434
$string = $this->getJsonString('09_errors.json');
35-
$document = Helper::parse($string);
35+
$document = Helper::parseResponseBody($string);
3636

3737
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
3838
$this->assertTrue($document->has('errors'));
@@ -107,7 +107,7 @@ public function testParseErrors()
107107
public function testParseErrorWithLinks()
108108
{
109109
$string = $this->getJsonString('10_error_with_links.json');
110-
$document = Helper::parse($string);
110+
$document = Helper::parseResponseBody($string);
111111

112112
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
113113
$this->assertTrue($document->has('errors'));

tests/Integration/ParsingTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ParsingTest extends \Art4\JsonApiClient\Tests\Fixtures\TestCase
3232
public function testParseSimpleResource()
3333
{
3434
$string = $this->getJsonString('01_simple_resource.json');
35-
$document = Helper::parse($string);
35+
$document = Helper::parseResponseBody($string);
3636

3737
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
3838
$this->assertFalse($document->has('errors'));
@@ -63,7 +63,7 @@ public function testParseSimpleResource()
6363
public function testParseSimpleResourceIdentifier()
6464
{
6565
$string = $this->getJsonString('02_simple_resource_identifier.json');
66-
$document = Helper::parse($string);
66+
$document = Helper::parseResponseBody($string);
6767

6868
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
6969
$this->assertFalse($document->has('errors'));
@@ -90,7 +90,7 @@ public function testParseSimpleResourceIdentifier()
9090
public function testParseResourceObject()
9191
{
9292
$string = $this->getJsonString('03_resource_object.json');
93-
$document = Helper::parse($string);
93+
$document = Helper::parseResponseBody($string);
9494

9595
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
9696
$this->assertFalse($document->has('errors'));
@@ -161,7 +161,7 @@ public function testParseResourceObject()
161161
public function testParseCompleteResourceObjectWithMultipleRelationships()
162162
{
163163
$string = $this->getJsonString('04_complete_document_with_multiple_relationships.json');
164-
$document = Helper::parse($string);
164+
$document = Helper::parseResponseBody($string);
165165

166166
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
167167
$this->assertFalse($document->has('errors'));
@@ -339,7 +339,7 @@ public function testParseCompleteResourceObjectWithMultipleRelationships()
339339
public function testParsePaginationExample()
340340
{
341341
$string = $this->getJsonString('06_pagination_example.json');
342-
$document = Helper::parse($string);
342+
$document = Helper::parseResponseBody($string);
343343

344344
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
345345
$this->assertTrue($document->has('data'));
@@ -396,7 +396,7 @@ public function testParsePaginationExample()
396396
public function testParseRelationshipExample()
397397
{
398398
$string = $this->getJsonString('07_relationship_example_without_data.json');
399-
$document = Helper::parse($string);
399+
$document = Helper::parseResponseBody($string);
400400

401401
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
402402
$this->assertTrue($document->has('data'));
@@ -465,7 +465,7 @@ public function testParseRelationshipExample()
465465
public function testParseObjectLinksExample()
466466
{
467467
$string = $this->getJsonString('08_object_links.json');
468-
$document = Helper::parse($string);
468+
$document = Helper::parseResponseBody($string);
469469

470470
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
471471
$this->assertTrue($document->has('links'));
@@ -511,7 +511,7 @@ public function testParseObjectLinksExample()
511511
public function testParseResourceIdentifierWithMeta()
512512
{
513513
$string = $this->getJsonString('11_resource_identifier_with_meta.json');
514-
$document = Helper::parse($string);
514+
$document = Helper::parseResponseBody($string);
515515

516516
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
517517
$this->assertFalse($document->has('errors'));
@@ -540,7 +540,7 @@ public function testParseResourceIdentifierWithMeta()
540540
public function testParseNullResource()
541541
{
542542
$string = $this->getJsonString('12_null_resource.json');
543-
$document = Helper::parse($string);
543+
$document = Helper::parseResponseBody($string);
544544

545545
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
546546
$this->assertFalse($document->has('errors'));
@@ -564,7 +564,7 @@ public function testParseNullResource()
564564
public function testParseResourceIdentifierCollectionWithMeta()
565565
{
566566
$string = $this->getJsonString('13_collection_with_resource_identifier_with_meta.json');
567-
$document = Helper::parse($string);
567+
$document = Helper::parseResponseBody($string);
568568

569569
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
570570
$this->assertFalse($document->has('errors'));

tests/Unit/Utils/HelperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testParseWithValidJsonapiReturnsDocument()
161161
{
162162
$jsonapi = '{"meta":{}}';
163163

164-
$this->assertInstanceOf('Art4\JsonApiClient\Document', Helper::parse($jsonapi));
164+
$this->assertInstanceOf('Art4\JsonApiClient\Document', Helper::parseResponseBody($jsonapi));
165165
}
166166

167167
/**
@@ -173,7 +173,7 @@ public function testParseWithInvalidJsonapiThrowsException()
173173
{
174174
$invalid_jsonapi = '["This is valid JSON", "but invalid JSON API"]';
175175

176-
$output = Helper::parse($invalid_jsonapi);
176+
$output = Helper::parseResponseBody($invalid_jsonapi);
177177
}
178178

179179
/**
@@ -185,7 +185,7 @@ public function testParseWithInvalidJsonThrowsException()
185185
{
186186
$invalid_json = 'invalid_json_string';
187187

188-
$output = Helper::parse($invalid_json);
188+
$output = Helper::parseResponseBody($invalid_json);
189189
}
190190

191191
/**

0 commit comments

Comments
 (0)