Completed
Pull Request — master (#513)
by Helpful
04:05
created

PipelineNotificationTest::testSendSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %
Metric Value
dl 15
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
/**
4
 * Tests the pipeline notification process
5
 */
6
class PipelineNotificationTest extends PipelineTest {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
29
		$pipeline = $this->getDummyPipeline();
30
31
		// Assert dependencies are injected
32
		$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService);
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
		$pipeline->start();
34
		$this->logInWithPermission('ADMIN');
35
		$pipeline->markComplete();
36
37
		// Assert not error at startup
38
		$this->assertEquals('Complete', $pipeline->Status);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
48
		$pipeline = $this->getDummyPipeline();
49
50
		// Assert dependencies are injected
51
		$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService);
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
		$pipeline->start();
53
		$this->logInWithPermission('ADMIN');
54
		$pipeline->markAborted();
55
56
		// Assert not error at startup
57
		$this->assertEquals('Aborted', $pipeline->Status);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
67
		$pipeline = $this->getDummyPipeline();
68
69
		// Assert dependencies are injected
70
		$this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService);
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
		$pipeline->start();
72
		$this->logInWithPermission('ADMIN');
73
		$pipeline->markFailed();
74
75
		// Assert not error at startup
76
		$this->assertEquals('Failed', $pipeline->Status);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PipelineNotificationTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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