Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10341933
JenkinsPayloadAnalyzerTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
JenkinsPayloadAnalyzerTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Analyzers
;
use
Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer
;
use
Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration
;
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
()
{
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
(
$status
,
$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
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jul 2, 21:34 (2 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2779818
Default Alt Text
JenkinsPayloadAnalyzerTest.php (2 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment