|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Tests the pipeline notification process |
|
5
|
|
|
*/ |
|
6
|
|
|
class PipelineNotificationTest extends PipelineTest { |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
protected static $fixture_file = 'PipelineTest.yml'; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Makes the dummy pipeline |
|
12
|
|
|
* |
|
13
|
|
|
* @return Pipeline |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getDummyPipeline() { |
|
16
|
|
|
// Load data into step and pipeline |
|
17
|
|
|
$data = $this->getPipelineConfig(); |
|
18
|
|
|
$pipeline = $this->objFromFixture('Pipeline', 'testpipe'); |
|
19
|
|
|
$pipeline->Config = serialize($data); |
|
20
|
|
|
$pipeline->write(); |
|
21
|
|
|
|
|
22
|
|
|
return $pipeline; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Test success notification |
|
27
|
|
|
*/ |
|
28
|
|
View Code Duplication |
public function testSendSuccess() { |
|
|
|
|
|
|
29
|
|
|
$pipeline = $this->getDummyPipeline(); |
|
30
|
|
|
|
|
31
|
|
|
// Assert dependencies are injected |
|
32
|
|
|
$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); |
|
|
|
|
|
|
33
|
|
|
$pipeline->start(); |
|
34
|
|
|
$this->logInWithPermission('ADMIN'); |
|
35
|
|
|
$pipeline->markComplete(); |
|
36
|
|
|
|
|
37
|
|
|
// Assert not error at startup |
|
38
|
|
|
$this->assertEquals('Complete', $pipeline->Status); |
|
|
|
|
|
|
39
|
|
|
$this->assertHasLog('Pipeline completed successfully.'); |
|
40
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has successfully completed', '[email protected]'); |
|
41
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has successfully completed', '[email protected]'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Test abort |
|
46
|
|
|
*/ |
|
47
|
|
View Code Duplication |
public function testSendAbort() { |
|
|
|
|
|
|
48
|
|
|
$pipeline = $this->getDummyPipeline(); |
|
49
|
|
|
|
|
50
|
|
|
// Assert dependencies are injected |
|
51
|
|
|
$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); |
|
|
|
|
|
|
52
|
|
|
$pipeline->start(); |
|
53
|
|
|
$this->logInWithPermission('ADMIN'); |
|
54
|
|
|
$pipeline->markAborted(); |
|
55
|
|
|
|
|
56
|
|
|
// Assert not error at startup |
|
57
|
|
|
$this->assertEquals('Aborted', $pipeline->Status); |
|
|
|
|
|
|
58
|
|
|
$this->assertHasLog('Pipeline processing aborted. ADMIN User ([email protected]) aborted the pipeline'); |
|
59
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has been aborted', '[email protected]'); |
|
60
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has been aborted', '[email protected]'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Test abort |
|
65
|
|
|
*/ |
|
66
|
|
View Code Duplication |
public function testSendFailure() { |
|
|
|
|
|
|
67
|
|
|
$pipeline = $this->getDummyPipeline(); |
|
68
|
|
|
|
|
69
|
|
|
// Assert dependencies are injected |
|
70
|
|
|
$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); |
|
|
|
|
|
|
71
|
|
|
$pipeline->start(); |
|
72
|
|
|
$this->logInWithPermission('ADMIN'); |
|
73
|
|
|
$pipeline->markFailed(); |
|
74
|
|
|
|
|
75
|
|
|
// Assert not error at startup |
|
76
|
|
|
$this->assertEquals('Failed', $pipeline->Status); |
|
|
|
|
|
|
77
|
|
|
$this->assertHasLog('Pipeline failed, not running rollback (not configured or not applicable yet).'); |
|
78
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has failed', '[email protected]'); |
|
79
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has failed', '[email protected]'); |
|
80
|
|
|
$this->assertSentMessage('Deployment for testproject/uat has failed', '[email protected]'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.