| Total Complexity | 6 |
| Total Lines | 90 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class AssertableResponse extends DecodableResponse |
||
| 8 | { |
||
| 9 | |||
| 10 | use ContentAssertions; |
||
| 11 | use Statusable; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Assert that the response has a successful status code. |
||
| 15 | * |
||
| 16 | * @return $this |
||
| 17 | */ |
||
| 18 | public function assertSuccessful() |
||
| 19 | { |
||
| 20 | |||
| 21 | PHPUnit::assertTrue( |
||
| 22 | $this->isSuccessful(), |
||
| 23 | "Response status code [{$this->getStatusCode()}] is not a successful status code." |
||
| 24 | ); |
||
| 25 | |||
| 26 | return $this; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Assert that the response has the given status code. |
||
| 31 | * |
||
| 32 | * @param int $status |
||
| 33 | * @return $this |
||
| 34 | */ |
||
| 35 | public function assertStatus($status) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Assert whether the response is redirecting to a given URI. |
||
| 50 | * |
||
| 51 | * @param string $uri |
||
| 52 | * @return $this |
||
| 53 | */ |
||
| 54 | public function assertRedirect($uri = null) |
||
| 55 | { |
||
| 56 | |||
| 57 | PHPUnit::assertTrue( |
||
| 58 | $this->isRedirect(), |
||
| 59 | "Response status code [{$this->getStatusCode()}] is not a redirect status code." |
||
| 60 | ); |
||
| 61 | |||
| 62 | if (! is_null($uri)) { |
||
| 63 | PHPUnit::assertContains(app('url')->to($uri), $this->getHeader('Location'), '', true); |
||
|
|
|||
| 64 | } |
||
| 65 | |||
| 66 | return $this; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Asserts that the response contains the given header and equals the optional value. |
||
| 71 | * |
||
| 72 | * @param string $headerName |
||
| 73 | * @param mixed $value |
||
| 74 | * @return $this |
||
| 75 | */ |
||
| 76 | public function assertHeader($headerName, $value = null) |
||
| 97 | } |
||
| 98 | } |
||
| 99 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.