File tree Expand file tree Collapse file tree 5 files changed +58
-11
lines changed
tests/lib/Integration/Queue Expand file tree Collapse file tree 5 files changed +58
-11
lines changed Original file line number Diff line number Diff line change 17
17
18
18
namespace CloudCreativity \LaravelJsonApi \Http \Requests ;
19
19
20
+ use CloudCreativity \LaravelJsonApi \Contracts \Validators \ValidatorProviderInterface ;
21
+
20
22
/**
21
23
* Class FetchResource
22
24
*
@@ -33,4 +35,25 @@ public function getProcessId(): string
33
35
return $ this ->jsonApiRequest ->getProcessId ();
34
36
}
35
37
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ protected function validateQuery ()
42
+ {
43
+ if (!$ validators = $ this ->getValidators ()) {
44
+ return ;
45
+ }
46
+
47
+ /** Pre-1.0 validators */
48
+ if ($ validators instanceof ValidatorProviderInterface) {
49
+ $ validators ->resourceQueryChecker ()->checkQuery ($ this ->getEncodingParameters ());
50
+ return ;
51
+ }
52
+
53
+ /** 1.0 validators */
54
+ $ this ->passes (
55
+ $ validators ->fetchQuery ($ this ->query ())
56
+ );
57
+ }
58
+
36
59
}
Original file line number Diff line number Diff line change 17
17
18
18
namespace CloudCreativity \LaravelJsonApi \Http \Requests ;
19
19
20
+ use CloudCreativity \LaravelJsonApi \Contracts \Validators \ValidatorProviderInterface ;
21
+
20
22
/**
21
23
* Class FetchResources
22
24
*
@@ -55,15 +57,30 @@ protected function authorize()
55
57
*/
56
58
protected function validateQuery ()
57
59
{
58
- // @TODO
59
- // if (!$validators = $this->getValidators()) {
60
- // return;
61
- // }
62
- //
63
- // /** 1.0 validators */
64
- // $this->passes(
65
- // $validators->fetchManyQuery($this->query())
66
- // );
60
+ if (!$ validators = $ this ->getValidators ()) {
61
+ return ;
62
+ }
63
+
64
+ /** Pre-1.0 validators */
65
+ if ($ validators instanceof ValidatorProviderInterface) {
66
+ $ validators ->searchQueryChecker ()->checkQuery ($ this ->getEncodingParameters ());
67
+ return ;
68
+ }
69
+
70
+ /** 1.0 validators */
71
+ $ this ->passes (
72
+ $ validators ->fetchManyQuery ($ this ->query ())
73
+ );
74
+ }
75
+
76
+ /**
77
+ * @inheritdoc
78
+ */
79
+ protected function getValidators ()
80
+ {
81
+ return $ this ->container ->getValidatorsByResourceType (
82
+ $ this ->getProcessType ()
83
+ );
67
84
}
68
85
69
86
}
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ abstract class ValidatedRequest implements ValidatesWhenResolved
55
55
/**
56
56
* @var ContainerInterface
57
57
*/
58
- private $ container ;
58
+ protected $ container ;
59
59
60
60
/**
61
61
* Authorize the request.
Original file line number Diff line number Diff line change @@ -44,5 +44,4 @@ protected function queryRules(): array
44
44
return [];
45
45
}
46
46
47
-
48
47
}
Original file line number Diff line number Diff line change @@ -68,6 +68,14 @@ public function testReadNotFound()
68
68
->assertStatus (404 );
69
69
}
70
70
71
+ public function testInvalidInclude ()
72
+ {
73
+ $ job = factory (ClientJob::class)->create ();
74
+
75
+ $ this ->getJsonApi ($ this ->jobUrl ($ job ) . '? ' . http_build_query (['include ' => 'foo ' ]))
76
+ ->assertStatus (400 );
77
+ }
78
+
71
79
/**
72
80
* @param ClientJob $job
73
81
* @param string|null $resourceType
You can’t perform that action at this time.
0 commit comments