Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
402 lars 1
<?php
2
 
3
namespace Illuminate\Testing\Concerns;
4
 
5
use Illuminate\Testing\Assert as PHPUnit;
6
 
7
trait AssertsStatusCodes
8
{
9
    /**
10
     * Assert that the response has a 200 "OK" status code.
11
     *
12
     * @return $this
13
     */
14
    public function assertOk()
15
    {
16
        return $this->assertStatus(200);
17
    }
18
 
19
    /**
20
     * Assert that the response has a 201 "Created" status code.
21
     *
22
     * @return $this
23
     */
24
    public function assertCreated()
25
    {
26
        return $this->assertStatus(201);
27
    }
28
 
29
    /**
30
     * Assert that the response has a 202 "Accepted" status code.
31
     *
32
     * @return $this
33
     */
34
    public function assertAccepted()
35
    {
36
        return $this->assertStatus(202);
37
    }
38
 
39
    /**
40
     * Assert that the response has the given status code and no content.
41
     *
42
     * @param  int  $status
43
     * @return $this
44
     */
45
    public function assertNoContent($status = 204)
46
    {
47
        $this->assertStatus($status);
48
 
49
        PHPUnit::assertEmpty($this->getContent(), 'Response content is not empty.');
50
 
51
        return $this;
52
    }
53
 
54
    /**
55
     * Assert that the response has a 301 "Moved Permanently" status code.
56
     *
57
     * @param  int  $status
58
     * @return $this
59
     */
60
    public function assertMovedPermanently()
61
    {
62
        return $this->assertStatus(301);
63
    }
64
 
65
    /**
66
     * Assert that the response has a 302 "Found" status code.
67
     *
68
     * @param  int  $status
69
     * @return $this
70
     */
71
    public function assertFound()
72
    {
73
        return $this->assertStatus(302);
74
    }
75
 
76
    /**
77
     * Assert that the response has a 400 "Bad Request" status code.
78
     *
79
     * @return $this
80
     */
81
    public function assertBadRequest()
82
    {
83
        return $this->assertStatus(400);
84
    }
85
 
86
    /**
87
     * Assert that the response has a 401 "Unauthorized" status code.
88
     *
89
     * @return $this
90
     */
91
    public function assertUnauthorized()
92
    {
93
        return $this->assertStatus(401);
94
    }
95
 
96
    /**
97
     * Assert that the response has a 402 "Payment Required" status code.
98
     *
99
     * @return $this
100
     */
101
    public function assertPaymentRequired()
102
    {
103
        return $this->assertStatus(402);
104
    }
105
 
106
    /**
107
     * Assert that the response has a 403 "Forbidden" status code.
108
     *
109
     * @return $this
110
     */
111
    public function assertForbidden()
112
    {
113
        return $this->assertStatus(403);
114
    }
115
 
116
    /**
117
     * Assert that the response has a 404 "Not Found" status code.
118
     *
119
     * @return $this
120
     */
121
    public function assertNotFound()
122
    {
123
        return $this->assertStatus(404);
124
    }
125
 
126
    /**
127
     * Assert that the response has a 408 "Request Timeout" status code.
128
     *
129
     * @return $this
130
     */
131
    public function assertRequestTimeout()
132
    {
133
        return $this->assertStatus(408);
134
    }
135
 
136
    /**
137
     * Assert that the response has a 409 "Conflict" status code.
138
     *
139
     * @return $this
140
     */
141
    public function assertConflict()
142
    {
143
        return $this->assertStatus(409);
144
    }
145
 
146
    /**
147
     * Assert that the response has a 422 "Unprocessable Entity" status code.
148
     *
149
     * @return $this
150
     */
151
    public function assertUnprocessable()
152
    {
153
        return $this->assertStatus(422);
154
    }
155
 
156
    /**
157
     * Assert that the response has a 429 "Too Many Requests" status code.
158
     *
159
     * @return $this
160
     */
161
    public function assertTooManyRequests()
162
    {
163
        return $this->assertStatus(429);
164
    }
165
}