|
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
|
|
|
/** @test */ |
|
29
|
|
|
public function shouldReturnUserAvatarWithSize(): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->get('/avatar/200/_Cyb3r'); |
|
32
|
|
|
$actualImage = $this->response->getContent(); |
|
33
|
|
|
$expectedImage = \file_get_contents(base_path('tests/images/_Cyb3r_avatar_200.png')); |
|
34
|
|
|
$this->assertEquals($expectedImage, $actualImage); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** @test */ |
|
38
|
|
|
public function shouldReturnSteveSkin(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$this->get('/skin/Steve'); |
|
41
|
|
|
$actualImage = $this->response->getContent(); |
|
42
|
|
|
$expectedImage = \file_get_contents(base_path('tests/images/steve_skin.png')); |
|
43
|
|
|
$this->assertEquals($expectedImage, $actualImage); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** @test */ |
|
47
|
|
|
public function shouldReturnSteveSkinBack(): void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->get('/skin-back/Steve'); |
|
50
|
|
|
$actualImage = $this->response->getContent(); |
|
51
|
|
|
$expectedImage = \file_get_contents(base_path('tests/images/steve_skin_back.png')); |
|
52
|
|
|
$this->assertEquals($expectedImage, $actualImage); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function shouldReturnSteveHead(): void |
|
56
|
|
|
{ |
|
57
|
|
|
$this->get('/head/Steve'); |
|
58
|
|
|
$actualImage = $this->response->getContent(); |
|
59
|
|
|
$expectedImage = \file_get_contents(base_path('tests/images/steve_head.png')); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertEquals($expectedImage, $actualImage); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** @test */ |
|
65
|
|
|
public function shouldDownloadSteveTexture(): void |
|
66
|
|
|
{ |
|
67
|
|
|
$this->get('/download/Steve'); |
|
68
|
|
|
$actualImage = $this->response->getContent(); |
|
69
|
|
|
$expectedImage = \file_get_contents(base_path('tests/images/steve_raw.png')); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertEquals($expectedImage, $actualImage); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* NOT WORKING. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function shouldFailUpdatingUnExistingUser(): void |
|
78
|
|
|
{ |
|
79
|
|
|
$this->get('/update/_Cyb3r_Mega_Fail'); |
|
80
|
|
|
|
|
81
|
|
|
$expectedStatusCode = 404; |
|
82
|
|
|
$expectedContentType = 'application/json'; |
|
83
|
|
|
$this->assertEquals($expectedContentType, $this->response->headers->get('Content-Type')); |
|
84
|
|
|
$this->assertEquals($expectedStatusCode, $this->response->getStatusCode()); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|