Total Complexity | 14 |
Total Lines | 92 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait DeterminesAssertions |
||
8 | { |
||
9 | /** |
||
10 | * @return bool |
||
11 | */ |
||
12 | protected function shouldAssertAuthentication() |
||
13 | { |
||
14 | return $this->shouldReturnsStatus(Response::HTTP_UNAUTHORIZED); |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @param int $statusCode |
||
19 | * @return bool |
||
20 | */ |
||
21 | protected function shouldReturnsStatus($statusCode) |
||
22 | { |
||
23 | return collect($this->statusCodes())->contains($statusCode); |
||
|
|||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return bool |
||
28 | */ |
||
29 | protected function shouldAssertNotFound() |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return bool |
||
36 | */ |
||
37 | protected function shouldAssertValidation() |
||
38 | { |
||
39 | return $this->shouldReturnsStatus(Response::HTTP_UNPROCESSABLE_ENTITY); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return bool |
||
44 | */ |
||
45 | protected function shouldAssertForbiddenAction() |
||
46 | { |
||
47 | return $this->shouldReturnsStatus(Response::HTTP_FORBIDDEN); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return bool |
||
52 | */ |
||
53 | protected function shouldAssertCreation() |
||
54 | { |
||
55 | return $this->shouldReturnsStatus(Response::HTTP_CREATED); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return bool |
||
60 | */ |
||
61 | protected function shouldAssertUpdate() |
||
62 | { |
||
63 | return $this->shouldReturnsStatus(Response::HTTP_ACCEPTED); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param $httpAction |
||
68 | * @return bool |
||
69 | */ |
||
70 | protected function shouldAssertRetrieve($httpAction) |
||
71 | { |
||
72 | return $this->shouldReturnsStatus(Response::HTTP_OK) && !$this->isListAction($httpAction); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param $httpAction |
||
77 | * @return bool |
||
78 | */ |
||
79 | protected function isListAction($httpAction) |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param $httpAction |
||
86 | * @return bool |
||
87 | */ |
||
88 | protected function shouldAssertListAll($httpAction) |
||
89 | { |
||
90 | return $this->shouldReturnsStatus(Response::HTTP_OK) && $this->isListAction($httpAction); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @return bool |
||
95 | */ |
||
96 | protected function shouldAssertDeletion() |
||
99 | } |
||
100 | } |
||
101 |