Passed
Push — master ( 032fef...5c3390 )
by Mattia
03:11
created

JsonControllerTest::shouldReturnMostWantedUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 1
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
class JsonControllerTest extends TestCase
6
{
7
    public function setUp(): void
8
    {
9
        parent::setUp();
10
        \DB::beginTransaction();
11
    }
12
13
    public function tearDown(): void
14
    {
15
        \DB::rollBack();
16
        parent::tearDown();
17
    }
18
19
    /**
20
     * @test
21
     */
22
    public function shouldReturnTypeaheadEntries(): void
23
    {
24
        $this->get('/api/v1/typeahead/Cy');
25
        $this->assertJson($this->response->content());
26
    }
27
28
    /**
29
     * @test
30
     */
31
    public function shouldReturnUserDataUsingUuid(): void
32
    {
33
        $this->get('/api/v1/user/d59dcabb30424b978f7201d1a076637f');
34
        $responseContent = $this->response->content();
35
        $this->assertJson($responseContent);
36
        $this->seeJsonStructure(['ok', 'data'], $responseContent);
0 ignored issues
show
Bug introduced by
$responseContent of type string is incompatible with the type array|null expected by parameter $responseData of Laravel\Lumen\Testing\TestCase::seeJsonStructure(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $this->seeJsonStructure(['ok', 'data'], /** @scrutinizer ignore-type */ $responseContent);
Loading history...
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function shouldNotReturnUserDataUsingInvalidUuid(): void
43
    {
44
        $this->get('/api/v1/user/d59dcabb30424b978f7201ffffffffff');
45
        $responseContent = $this->response->content();
46
        $this->assertResponseStatus(404);
47
        $this->assertJson($responseContent);
48
        $this->seeJsonStructure(['ok', 'message'], $responseContent);
0 ignored issues
show
Bug introduced by
$responseContent of type string is incompatible with the type array|null expected by parameter $responseData of Laravel\Lumen\Testing\TestCase::seeJsonStructure(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
        $this->seeJsonStructure(['ok', 'message'], /** @scrutinizer ignore-type */ $responseContent);
Loading history...
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function shouldReturnUserDataUsingUsername(): void
55
    {
56
        $this->get('/api/v1/user/_Cyb3r');
57
        $responseContent = $this->response->content();
58
        $this->assertJson($responseContent);
59
        $this->seeJsonStructure(['ok', 'data'], $responseContent);
0 ignored issues
show
Bug introduced by
$responseContent of type string is incompatible with the type array|null expected by parameter $responseData of Laravel\Lumen\Testing\TestCase::seeJsonStructure(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
        $this->seeJsonStructure(['ok', 'data'], /** @scrutinizer ignore-type */ $responseContent);
Loading history...
60
    }
61
62
    /**
63
     * @test
64
     */
65
    public function shouldReturnMostWantedUser(): void
66
    {
67
        $this->get('/api/v1/stats/user/most-wanted');
68
        $responseContent = $this->response->content();
69
        $this->assertJson($responseContent);
70
        $this->seeJsonStructure(['ok', 'data'], $responseContent);
0 ignored issues
show
Bug introduced by
$responseContent of type string is incompatible with the type array|null expected by parameter $responseData of Laravel\Lumen\Testing\TestCase::seeJsonStructure(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

70
        $this->seeJsonStructure(['ok', 'data'], /** @scrutinizer ignore-type */ $responseContent);
Loading history...
71
    }
72
}
73