Passed
Push — master ( 0a47c1...5b0c2e )
by Mattia
23:08
created

ApiControllerTest::shouldReturnSteveAvatar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
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/Steve');
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
     * NOT WORKING.
75
     */
76
    public function shouldFailUpdatingUnExistingUser(): void
77
    {
78
        $this->get('/update/_Cyb3r_Mega_Fail');
79
80
        $expectedStatusCode = 404;
81
        $expectedContentType = 'application/json';
82
        $this->assertEquals($expectedContentType, $this->response->headers->get('Content-Type'));
83
        $this->assertEquals($expectedStatusCode, $this->response->getStatusCode());
84
    }
85
}
86