AssertNoContent::assertIsNoContentResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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