Completed
Push — master ( e6c6cd...40a6c9 )
by Iman
07:55
created

Response::assert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure\Expectations;
4
5
use Imanghafoori\HeyMan\MakeSure\Chain;
6
7
class Response
8
{
9
    private $chain;
10
11
    /**
12
     * Response constructor.
13
     *
14 18
     * @param $chain
15
     */
16 18
    public function __construct(Chain $chain)
17 18
    {
18
        $this->chain = $chain;
19 2
    }
20
21 2
    public function redirect($url, $status = null)
22
    {
23 2
        $this->chain->addAssertion('assertRedirect', $url);
24 2
25
        if (!is_null($status)) {
26
            $this->statusCode($status);
27 2
        }
28
29
        return $this;
30 14
    }
31
32 14
    public function statusCode($code)
33
    {
34 14
        $this->chain->addAssertion('assertStatus', $code);
35
36
        return $this;
37 2
    }
38
39 2
    public function success()
40 2
    {
41
        $this->chain->addAssertion('assertSuccessful');
42 1
    }
43
44 1
    public function withError($value)
45
    {
46 1
        $this->chain->addAssertion('assertSessionHasErrors', $value);
47
        return $this;
48
    }
49 9
50
    public function forbiddenStatus()
51 9
    {
52
        return $this->statusCode(403);
53
    }
54
}
55