Skip to content

Commit 6555627

Browse files
committed
Add some more spec tests
1 parent 6508e0d commit 6555627

File tree

2 files changed

+80
-10
lines changed

2 files changed

+80
-10
lines changed

src/Core/Document/ErrorList.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ public function push(Error ...$errors): self
9797
return $this;
9898
}
9999

100-
/**
101-
* Get the first error.
102-
*
103-
* @return Error|null
104-
*/
105-
public function first(): ?Error
106-
{
107-
return $this->stack[0] ?? null;
108-
}
109-
110100
/**
111101
* @return bool
112102
*/

tests/lib/Integration/Spec/ResourceTest.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,56 @@ public function createProvider(): array
301301
'source' => ['pointer' => '/data/relationships/author/data'],
302302
],
303303
],
304+
'data.relationships.*.data.type:required' => [
305+
[
306+
'data' => [
307+
'type' => 'posts',
308+
'attributes' => [
309+
'title' => 'Hello World',
310+
'content' => '...',
311+
'slug' => 'hello-world',
312+
],
313+
'relationships' => [
314+
'author' => [
315+
'data' => [
316+
'id' => '123',
317+
],
318+
],
319+
],
320+
],
321+
],
322+
[
323+
'title' => 'Non-Compliant JSON API Document',
324+
'detail' => "The member data must be an object.",
325+
'status' => '400',
326+
'source' => ['pointer' => '/data/relationships/author/data'],
327+
],
328+
],
329+
'data.relationships.*.data.id:required' => [
330+
[
331+
'data' => [
332+
'type' => 'posts',
333+
'attributes' => [
334+
'title' => 'Hello World',
335+
'content' => '...',
336+
'slug' => 'hello-world',
337+
],
338+
'relationships' => [
339+
'author' => [
340+
'data' => [
341+
'type' => 'users',
342+
],
343+
],
344+
],
345+
],
346+
],
347+
[
348+
'title' => 'Non-Compliant JSON API Document',
349+
'detail' => "The member data must be an object.",
350+
'status' => '400',
351+
'source' => ['pointer' => '/data/relationships/author/data'],
352+
],
353+
],
304354
'data.relationships.*.data:resource does not exist' => [
305355
[
306356
'data' => [
@@ -382,6 +432,36 @@ public function createProvider(): array
382432
'source' => ['pointer' => '/data/relationships/tags/data/0'],
383433
],
384434
],
435+
'data.relationships.*.data.*.id:required' => [
436+
[
437+
'data' => [
438+
'type' => 'posts',
439+
'attributes' => [
440+
'title' => 'Hello World',
441+
'content' => '...',
442+
'slug' => 'hello-world',
443+
],
444+
'relationships' => [
445+
'author' => [
446+
'data' => null,
447+
],
448+
'tags' => [
449+
'data' => [
450+
[
451+
'type' => 'tags',
452+
],
453+
],
454+
],
455+
],
456+
],
457+
],
458+
[
459+
'title' => 'Non-Compliant JSON API Document',
460+
'detail' => "The member type is required.",
461+
'status' => '400',
462+
'source' => ['pointer' => '/data/relationships/tags/data/0'],
463+
],
464+
],
385465
'data.relationships.*.data.*:resource does not exist' => [
386466
[
387467
'data' => [

0 commit comments

Comments
 (0)