Passed
Push — master ( df9d50...7f420f )
by Mattia
03:11
created

shouldGenerateAvatarUsingDifferentUuidFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
class ApiControllerTest 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 shouldReturnSteveAvatar(): void
23
    {
24
        $this->get('/avatar/Steve');
25
        $actualImage = $this->response->getContent();
26
        $expectedImage = \file_get_contents(base_path('tests/images/steve_avatar.png'));
27
        $this->assertEquals($expectedImage, $actualImage);
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function shouldReturnUserAvatarWithSize(): void
34
    {
35
        $this->get('/avatar/200/_Cyb3r');
36
        $actualImage = $this->response->getContent();
37
        $expectedImage = \file_get_contents(base_path('tests/images/_Cyb3r_avatar_200.png'));
38
        $this->assertEquals($expectedImage, $actualImage);
39
    }
40
41
    /**
42
     * @test
43
     */
44
    public function shouldReturnSteveSkin(): void
45
    {
46
        $this->get('/skin/Steve');
47
        $actualImage = $this->response->getContent();
48
        $expectedImage = \file_get_contents(base_path('tests/images/steve_skin.png'));
49
        $this->assertEquals($expectedImage, $actualImage);
50
    }
51
52
    /**
53
     * @test
54
     */
55
    public function shouldReturnSteveSkinBack(): void
56
    {
57
        $this->get('/skin-back/Steve');
58
        $actualImage = $this->response->getContent();
59
        $expectedImage = \file_get_contents(base_path('tests/images/steve_skin_back.png'));
60
        $this->assertEquals($expectedImage, $actualImage);
61
    }
62
63
    /**
64
     * @test
65
     */
66
    public function shouldReturnSteveHead(): void
67
    {
68
        $this->get('/head/Steve');
69
        $actualImage = $this->response->getContent();
70
        $expectedImage = \file_get_contents(base_path('tests/images/steve_head.png'));
71
72
        $this->assertEquals($expectedImage, $actualImage);
73
    }
74
75
    /**
76
     * @test
77
     */
78
    public function shouldDownloadSteveTexture(): void
79
    {
80
        $this->get('/download/8667ba71b85a4004af54457a9734eed7');
81
        $actualImage = $this->response->getContent();
82
        $expectedImage = \file_get_contents(base_path('tests/images/steve_raw.png'));
83
84
        $this->assertEquals($expectedImage, $actualImage);
85
    }
86
87
    /**
88
     * @test
89
     */
90
    public function shouldGenerateIsometricAvatar(): void
91
    {
92
        $this->get('/head/d59dcabb30424b978f7201d1a076637f');
93
        $this->assertResponseOk();
94
        $this->assertEquals(
95
            'image/png',
96
            $this->response->headers->get('Content-Type')
97
        );
98
    }
99
100
    /**
101
     * @test
102
     */
103
    public function shouldGenerateAvatarUsingDifferentUuidFormat(): void
104
    {
105
        $this->get('/avatar/d59dcabb-3042-4b97-8f72-01d1a076637f');
106
        $this->assertResponseOk();
107
        $this->assertEquals(
108
            'image/png',
109
            $this->response->headers->get('Content-Type')
110
        );
111
    }
112
113
    /**
114
     * @test
115
     */
116
    public function shouldFailUpdatingUnExistingUser(): void
117
    {
118
        $this->get('/update/d59dcabb30424b978f7201ffffffffff');
119
120
        $expectedStatusCode = 404;
121
        $expectedContentType = 'application/json';
122
        $this->assertEquals($expectedContentType, $this->response->headers->get('Content-Type'));
123
        $this->assertEquals($expectedStatusCode, $this->response->getStatusCode());
124
    }
125
}
126