1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Functional; |
4
|
|
|
|
5
|
|
|
class BasicTest extends AbstractTestCase |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
View Code Duplication |
public function testDeploy() |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
$response = $this->runApp( |
11
|
|
|
file_get_contents(__DIR__ . '/data/pipeline.json'), |
12
|
|
|
[ |
13
|
|
|
'HOOK_PROJECT_PATH' => 'gitlab-org/gitlab-test', |
14
|
|
|
'HOOK_BUILD_ID' => 379, |
15
|
|
|
'HOOK_BUILD_REF' => 'bcbb5ec396a2c0f828686f14fac9b80b780504f2', |
16
|
|
|
'HOOK_ENV_NAME' => 'staging' |
17
|
|
|
], |
18
|
|
|
'bash /testing-dir/script.bash deploy' |
19
|
|
|
); |
20
|
|
|
|
21
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
public function testPush() |
26
|
|
|
{ |
27
|
|
|
$response = $this->runApp( |
28
|
|
|
file_get_contents(__DIR__ . '/data/push.json'), |
29
|
|
|
[ |
30
|
|
|
'HOOK_PROJECT_PATH' => 'gitlab-org/gitlab-test', |
31
|
|
|
'HOOK_REF' => 'refs/heads/master', |
32
|
|
|
'HOOK_BRANCH' => 'master', |
33
|
|
|
'HOOK_BUILD_REF' => 'da1560886d4f094c3e6c9ef40349f7d38b5d27d7' |
34
|
|
|
], |
35
|
|
|
[ |
36
|
|
|
'cwd' => '/testing-dir', |
37
|
|
|
'command' => 'bash /testing-dir/script.bash push' |
38
|
|
|
] |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
View Code Duplication |
public function testPushTag() |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$response = $this->runApp( |
48
|
|
|
file_get_contents(__DIR__ . '/data/tag.json'), |
49
|
|
|
[ |
50
|
|
|
'HOOK_PROJECT_PATH' => 'jsmith/example', |
51
|
|
|
'HOOK_REF' => 'refs/tags/v1.0.0', |
52
|
|
|
'HOOK_TAG' => 'v1.0.0', |
53
|
|
|
'HOOK_BUILD_REF' => '82b3d5ae55f7080f1e6022629cdb57bfae7cccc7' |
54
|
|
|
], |
55
|
|
|
'bash /testing-dir/script.bash tag' |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function testNo() |
63
|
|
|
{ |
64
|
|
|
$response = $this->runInvalid(); |
65
|
|
|
|
66
|
|
|
$this->assertEquals(500, $response->getStatusCode()); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
public function testUnsecured() |
71
|
|
|
{ |
72
|
|
|
$response = $this->runUnsecured(); |
73
|
|
|
|
74
|
|
|
$this->assertEquals(403, $response->getStatusCode()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
public function testNotHandled() |
79
|
|
|
{ |
80
|
|
|
$response = $this->runNotHandled(); |
81
|
|
|
|
82
|
|
|
$this->assertEquals(404, $response->getStatusCode()); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.