Source of file PipelineNotificationTest.php
Size: 2,732 Bytes - Last Modified: 2021-12-23T10:29:15+00:00
/var/www/docs.ssmods.com/process/src/tests/PipelineNotificationTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | <?php /** * Tests the pipeline notification process */ class PipelineNotificationTest extends PipelineTest { protected static $fixture_file = 'PipelineTest.yml'; /** * Makes the dummy pipeline * * @return Pipeline */ public function getDummyPipeline() { // Load data into step and pipeline $data = $this->getPipelineConfig(); $pipeline = $this->objFromFixture('Pipeline', 'testpipe'); $pipeline->Config = serialize($data); $pipeline->write(); return $pipeline; } /** * Test success notification */ public function testSendSuccess() { $pipeline = $this->getDummyPipeline(); // Assert dependencies are injected $this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); $pipeline->start(); $this->logInWithPermission('ADMIN'); $pipeline->markComplete(); // Assert not error at startup $this->assertEquals('Complete', $pipeline->Status); $this->assertHasLog('Pipeline completed successfully.'); $this->assertSentMessage('Deployment for testproject/uat has successfully completed', 'success@example.com'); $this->assertSentMessage('Deployment for testproject/uat has successfully completed', 'test@example.com'); } /** * Test abort */ public function testSendAbort() { $pipeline = $this->getDummyPipeline(); // Assert dependencies are injected $this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); $pipeline->start(); $this->logInWithPermission('ADMIN'); $pipeline->markAborted(); // Assert not error at startup $this->assertEquals('Aborted', $pipeline->Status); $this->assertHasLog('Pipeline processing aborted. ADMIN User (ADMIN@example.org) aborted the pipeline'); $this->assertSentMessage('Deployment for testproject/uat has been aborted', 'abort@example.com'); $this->assertSentMessage('Deployment for testproject/uat has been aborted', 'test@example.com'); } /** * Test abort */ public function testSendFailure() { $pipeline = $this->getDummyPipeline(); // Assert dependencies are injected $this->assertTrue($pipeline->getMessagingService() instanceof ConfirmationMessagingService); $pipeline->start(); $this->logInWithPermission('ADMIN'); $pipeline->markFailed(); // Assert not error at startup $this->assertEquals('Failed', $pipeline->Status); $this->assertHasLog('Pipeline failed, not running rollback (not configured or not applicable yet).'); $this->assertSentMessage('Deployment for testproject/uat has failed', 'abort@example.com'); $this->assertSentMessage('Deployment for testproject/uat has failed', 'errors@example.com'); $this->assertSentMessage('Deployment for testproject/uat has failed', 'test@example.com'); } } |