1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fabrica\Bundle\CoreBundle\Tests\Command; |
4
|
|
|
|
5
|
|
|
use Fabrica\Bundle\CoreBundle\Test\CommandTestCase; |
6
|
|
|
|
7
|
|
|
class ProjectNotifyPushCommandTest extends CommandTestCase |
8
|
|
|
{ |
9
|
|
|
protected $client; |
10
|
|
|
|
11
|
|
|
protected function setUp(): void |
12
|
|
|
{ |
13
|
|
|
$this->client = self::createClient(); |
14
|
|
|
$this->client->startIsolation(); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function tearDown(): void |
18
|
|
|
{ |
19
|
|
|
$this->client->stopIsolation(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
View Code Duplication |
public function testSimpleCase() |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
list($statusCode, $output) = $this->execCommand('foobar', 'alice', '/refs/heads/master', 'd8930cd3f7e343195b85d56408a701feb98b95a8', '026537944abd3c0498b30e6d10916a64fe0988c4'); |
25
|
|
|
|
26
|
|
|
$this->assertEquals(0, $statusCode); |
27
|
|
|
$this->assertEquals(null, $output); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testUndefinedProjectCase() |
31
|
|
|
{ |
32
|
|
|
list($statusCode, $output) = $this->execCommand('example', 'alice', '/refs/heads/master', '0', '0'); |
33
|
|
|
|
34
|
|
|
$this->assertEquals(1, $statusCode); |
35
|
|
|
$this->assertEquals(null, $output); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
View Code Duplication |
public function testNewReferenceCase() |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
list($statusCode, $output) = $this->execCommand('foobar', 'alice', '/refs/heads/example', 'd8930cd3f7e343195b85d56408a701feb98b95a8', '026537944abd3c0498b30e6d10916a64fe0988c4'); |
41
|
|
|
|
42
|
|
|
$this->assertEquals(0, $statusCode); |
43
|
|
|
$this->assertEquals(null, $output); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
View Code Duplication |
public function testUndefinedUserCase() |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
list($statusCode, $output) = $this->execCommand('foobar', 'example', '/refs/heads/master', 'd8930cd3f7e343195b85d56408a701feb98b95a8', '026537944abd3c0498b30e6d10916a64fe0988c4'); |
49
|
|
|
|
50
|
|
|
$this->assertEquals(1, $statusCode); |
51
|
|
|
$this->assertEquals(null, $output); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function execCommand($project, $user, $reference, $before, $after) |
55
|
|
|
{ |
56
|
|
|
return $this->runCommand( |
57
|
|
|
$this->client, sprintf( |
58
|
|
|
'fabrica:project-notify-push %s %s %s %s %s', |
59
|
|
|
$project, $user, $reference, $before, $after |
60
|
|
|
) |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
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.