Page MenuHomeDevCentral

JenkinsPayloadAnalyzerTest.php
No OneTemporary

JenkinsPayloadAnalyzerTest.php

<?php
namespace Nasqueron\Notifications\Tests\Analyzers;
use Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer;
use Nasqueron\Notifications\Tests\TestCase;
class JenkinsPayloadAnalyzerTest extends TestCase {
/**
* Jenkins analyzer to a successful build
*
* @var \Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer
*/
protected $analyzer;
/**
* @var \stdClass
*/
protected $payload;
/**
* Prepares the test
*/
public function setUp (): void {
parent::setUp();
$filename = __DIR__ . '/../../data/payloads/JenkinsToIgnorePayload.json';
$this->payload = json_decode(file_get_contents($filename));
$this->analyzer = new JenkinsPayloadAnalyzer("Nasqueron", $this->payload);
}
public function testGetItemName () {
$this->assertSame("test-prod-env", $this->analyzer->getItemName());
}
public function testGetGroup () {
$this->assertSame("ops", $this->analyzer->getGroup());
}
public function testGetGroupWhenWeNeedDefaultFallback () {
$this->payload->name = "quux";
$this->assertSame("ci", $this->analyzer->getGroup());
}
public function testShouldNotifyWhenStatusIsUndefined () {
unset($this->payload->build->status);
$this->assertFalse($this->analyzer->shouldNotify());
}
/**
* @dataProvider payloadStatusProvider
*/
public function testShouldNotifyByStatus(string $status, bool $shouldNotify) {
$this->payload->build->status = $status;
$this->assertSame($shouldNotify, $this->analyzer->shouldNotify());
}
/**
* Provides data for testShouldNotifyByStatus
*
* @return array
*/
public function payloadStatusProvider () {
return [
// Build status to notify
["FAILURE", true],
["ABORTED", true],
["UNSTABLE", true],
// Build status to ignore
["SUCCESS", false],
["NOT_BUILT", false],
];
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 11, 22:36 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3064199
Default Alt Text
JenkinsPayloadAnalyzerTest.php (2 KB)

Event Timeline