Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793761
JenkinsNotificationTest.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
JenkinsNotificationTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Notifications
;
use
Nasqueron\Notifications\Notifications\JenkinsNotification
;
use
Nasqueron\Notifications\Tests\TestCase
;
class
JenkinsNotificationTest
extends
TestCase
{
/**
* @var \Nasqueron\Notifications\Notifications\JenkinsNotification
*/
private
$notification
;
/**
* @var \stdClass
*/
private
$payload
;
public
function
prepareNotification
(
$payloadFile
,
$project
=
"Acme"
)
{
$path
=
__DIR__
.
'/../data/payloads/'
.
$payloadFile
;
$this
->
payload
=
json_decode
(
file_get_contents
(
$path
));
$this
->
notification
=
new
JenkinsNotification
(
$project
,
$this
->
payload
);
}
public
function
testProperties
()
{
$this
->
prepareNotification
(
'JenkinsPayload.json'
);
$this
->
assertSame
(
"Jenkins"
,
$this
->
notification
->
service
);
$this
->
assertSame
(
"Acme"
,
$this
->
notification
->
project
);
$this
->
assertSame
(
"ci"
,
$this
->
notification
->
group
);
$this
->
assertSame
(
$this
->
payload
,
$this
->
notification
->
rawContent
);
$this
->
assertSame
(
"completed.success"
,
$this
->
notification
->
type
);
$this
->
assertSame
(
"Jenkins job asgard has been completed: success"
,
$this
->
notification
->
text
);
$this
->
assertSame
(
"http://localhost:8080/job/asgard/18/"
,
$this
->
notification
->
link
);
}
public
function
testPropertiesForIncompletePayload
()
{
$this
->
prepareNotification
(
'JenkinsStartedPayload.json'
);
$this
->
assertSame
(
"started"
,
$this
->
notification
->
type
);
$this
->
assertSame
(
"Jenkins job asgard has been started"
,
$this
->
notification
->
text
);
}
public
function
testShouldNotifyOnDefaultConfiguration
()
{
$this
->
prepareNotification
(
'JenkinsPayload.json'
);
$this
->
assertTrue
(
$this
->
notification
->
shouldNotify
());
}
public
function
testShouldNotifyWhenConfiguredNotTo
()
{
$this
->
prepareNotification
(
'JenkinsToIgnorePayload.json'
,
'Nasqueron'
);
$this
->
assertFalse
(
$this
->
notification
->
shouldNotify
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 22:47 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2437306
Default Alt Text
JenkinsNotificationTest.php (2 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment