Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 150 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 150 Revision 399
Zeile 30... Zeile 30...
30
/**
30
/**
31
 * @mixin \Illuminate\Http\Response
31
 * @mixin \Illuminate\Http\Response
32
 */
32
 */
33
class TestResponse implements ArrayAccess
33
class TestResponse implements ArrayAccess
34
{
34
{
35
    use Tappable, Macroable {
35
    use Concerns\AssertsStatusCodes, Tappable, Macroable {
36
        __call as macroCall;
36
        __call as macroCall;
37
    }
37
    }
Zeile 38... Zeile 38...
38
 
38
 
39
    /**
39
    /**
Zeile 94... Zeile 94...
94
 
94
 
95
        return $this;
95
        return $this;
Zeile 96... Zeile 96...
96
    }
96
    }
97
 
-
 
98
    /**
-
 
99
     * Assert that the response has a 200 status code.
-
 
100
     *
-
 
101
     * @return $this
-
 
102
     */
-
 
103
    public function assertOk()
-
 
104
    {
-
 
105
        return $this->assertStatus(200);
-
 
106
    }
-
 
107
 
-
 
108
    /**
-
 
109
     * Assert that the response has a 201 status code.
-
 
110
     *
-
 
111
     * @return $this
-
 
112
     */
-
 
113
    public function assertCreated()
-
 
114
    {
-
 
115
        return $this->assertStatus(201);
-
 
116
    }
-
 
117
 
-
 
118
    /**
-
 
119
     * Assert that the response has the given status code and no content.
-
 
120
     *
-
 
121
     * @param  int  $status
-
 
122
     * @return $this
-
 
123
     */
-
 
124
    public function assertNoContent($status = 204)
-
 
125
    {
-
 
126
        $this->assertStatus($status);
-
 
127
 
-
 
128
        PHPUnit::assertEmpty($this->getContent(), 'Response content is not empty.');
-
 
129
 
-
 
130
        return $this;
-
 
131
    }
-
 
132
 
-
 
133
    /**
-
 
134
     * Assert that the response has a not found status code.
-
 
135
     *
-
 
136
     * @return $this
-
 
137
     */
-
 
138
    public function assertNotFound()
-
 
139
    {
-
 
140
        return $this->assertStatus(404);
-
 
141
    }
-
 
142
 
-
 
143
    /**
-
 
144
     * Assert that the response has a forbidden status code.
-
 
145
     *
-
 
146
     * @return $this
-
 
147
     */
-
 
148
    public function assertForbidden()
-
 
149
    {
-
 
150
        return $this->assertStatus(403);
-
 
151
    }
-
 
152
 
-
 
153
    /**
-
 
154
     * Assert that the response has an unauthorized status code.
-
 
155
     *
-
 
156
     * @return $this
-
 
157
     */
-
 
158
    public function assertUnauthorized()
-
 
159
    {
-
 
160
        return $this->assertStatus(401);
-
 
161
    }
-
 
162
 
-
 
163
    /**
-
 
164
     * Assert that the response has a 422 status code.
-
 
165
     *
-
 
166
     * @return $this
-
 
167
     */
-
 
168
    public function assertUnprocessable()
-
 
169
    {
-
 
170
        return $this->assertStatus(422);
-
 
171
    }
-
 
172
 
97
 
173
    /**
98
    /**
174
     * Assert that the response is a server error.
99
     * Assert that the response is a server error.
175
     *
100
     *
176
     * @return $this
101
     * @return $this
Zeile 965... Zeile 890...
965
 
890
 
966
        return $this;
891
        return $this;
Zeile 967... Zeile 892...
967
    }
892
    }
-
 
893
 
-
 
894
    /**
-
 
895
     * Assert that the given key is a JSON array.
-
 
896
     *
-
 
897
     * @param $key
-
 
898
     * @return $this
-
 
899
     */
-
 
900
    public function assertJsonIsArray($key = null)
-
 
901
    {
-
 
902
        $data = $this->json($key);
-
 
903
 
-
 
904
        $encodedData = json_encode($data);
-
 
905
 
-
 
906
        PHPUnit::assertTrue(
-
 
907
            is_array($data)
-
 
908
            && str_starts_with($encodedData, '[')
-
 
909
            && str_ends_with($encodedData, ']')
-
 
910
        );
-
 
911
 
-
 
912
        return $this;
-
 
913
    }
-
 
914
 
-
 
915
    /**
-
 
916
     * Assert that the given key is a JSON object.
-
 
917
     *
-
 
918
     * @param $key
-
 
919
     * @return $this
-
 
920
     */
-
 
921
    public function assertJsonIsObject($key = null)
-
 
922
    {
-
 
923
        $data = $this->json($key);
-
 
924
 
-
 
925
        $encodedData = json_encode($data);
-
 
926
 
-
 
927
        PHPUnit::assertTrue(
-
 
928
            is_array($data)
-
 
929
            && str_starts_with($encodedData, '{')
-
 
930
            && str_ends_with($encodedData, '}')
-
 
931
        );
-
 
932
 
-
 
933
        return $this;
-
 
934
    }
968
 
935
 
969
    /**
936
    /**
970
     * Validate and return the decoded response JSON.
937
     * Validate and return the decoded response JSON.
971
     *
938
     *
972
     * @return \Illuminate\Testing\AssertableJsonString
939
     * @return \Illuminate\Testing\AssertableJsonString