AssertNoContent   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 5
c 1
b 0
f 0
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertIsNoContentResponse() 0 9 1
1
<?php
2
3
namespace VGirol\JsonApiAssert\Laravel\Asserts\Response;
4
5
use Illuminate\Testing\TestResponse;
6
use PHPUnit\Framework\Assert as PHPUnit;
7
use VGirol\JsonApiAssert\Laravel\HttpHeader;
8
9
/**
10
 * This trait adds the ability to test response with no content.
11
 */
12
trait AssertNoContent
13
{
14
    /**
15
     * Asserts that a response is a valid "204 No Content" response.
16
     *
17
     * @param TestResponse $response
18
     *
19
     * @return void
20
     * @throws \PHPUnit\Framework\AssertionFailedError
21
     */
22 18
    public static function assertIsNoContentResponse(TestResponse $response)
23
    {
24 18
        $response->assertStatus(204);
25 15
        $response->assertHeaderMissing(HttpHeader::HEADER_NAME);
26
27
        // Decode JSON response
28 9
        $content = $response->getContent();
29
30 9
        PHPUnit::assertEmpty($content);
31 6
    }
32
}
33