Passed
Push — master ( 2db671...7a423a )
by Mattia
03:54
created

shouldFailUpdatingUnExistingUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
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
    /** @test */
20
    public function shouldReturnSteveAvatar(): void
21
    {
22
        $this->get('/avatar/Steve');
23
        $actualImage = $this->response->getContent();
24
        $expectedImage = \file_get_contents(base_path('tests/images/steve_avatar.png'));
25
        $this->assertEquals($expectedImage, $actualImage);
26
    }
27
28
    public function shouldReturnUserAvatarWithSize(): void
29
    {
30
        $this->get('/avatar/200/_Cyb3r');
31
        $actualImage = $this->response->getContent();
32
        $expectedImage = \file_get_contents(base_path('tests/images/_Cyb3r_avatar_200.png'));
33
        $this->assertEquals($expectedImage, $actualImage);
34
    }
35
36
    /** @test */
37
    public function shouldReturnSteveSkin(): void
38
    {
39
        $this->get('/skin/Steve');
40
        $actualImage = $this->response->getContent();
41
        $expectedImage = \file_get_contents(base_path('tests/images/steve_skin.png'));
42
        $this->assertEquals($expectedImage, $actualImage);
43
    }
44
45
    /** @test */
46
    public function shouldReturnSteveSkinBack(): void
47
    {
48
        $this->get('/skin-back/Steve');
49
        $actualImage = $this->response->getContent();
50
        $expectedImage = \file_get_contents(base_path('tests/images/steve_skin_back.png'));
51
        $this->assertEquals($expectedImage, $actualImage);
52
    }
53
54
    public function shouldReturnSteveHead(): void
55
    {
56
        $this->get('/head/Steve');
57
        $actualImage = $this->response->getContent();
58
        $expectedImage = \file_get_contents(base_path('tests/images/steve_head.png'));
59
60
        $this->assertEquals($expectedImage, $actualImage);
61
    }
62
63
    /** @test */
64
    public function shouldDownloadSteveTexture(): void
65
    {
66
        $this->get('/download/8667ba71b85a4004af54457a9734eed7');
67
        $actualImage = $this->response->getContent();
68
        $expectedImage = \file_get_contents(base_path('tests/images/steve_raw.png'));
69
70
        $this->assertEquals($expectedImage, $actualImage);
71
    }
72
73
    /**
74
     * @test
75
     */
76
    public function shouldGenerateIsometricAvatar(): void
77
    {
78
        $this->get('/head/d59dcabb30424b978f7201d1a076637f');
79
        $this->assertResponseOk();
80
        $this->assertEquals(
81
            'image/png',
82
            $this->response->headers->get('Content-Type')
83
        );
84
    }
85
86
    /**
87
     * @test
88
     */
89
    public function shouldFailUpdatingUnExistingUser(): void
90
    {
91
        $this->get('/update/d59dcabb30424b978f7201ffffffffff');
92
93
        $expectedStatusCode = 404;
94
        $expectedContentType = 'application/json';
95
        $this->assertEquals($expectedContentType, $this->response->headers->get('Content-Type'));
96
        $this->assertEquals($expectedStatusCode, $this->response->getStatusCode());
97
    }
98
}
99