Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12239016
EventTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
EventTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Analyzers\GitHub\Events
;
use
Nasqueron\Notifications\Analyzers\GitHub\Events\Event
;
use
Nasqueron\Notifications\Tests\TestCase
;
use
InvalidArgumentException
;
class
EventTest
extends
TestCase
{
public
function
testGetClass
()
{
$this
->
assertSame
(
'Nasqueron
\N
otifications
\A
nalyzers
\G
itHub
\E
vents
\C
ommitCommentEvent'
,
Event
::
getClass
(
'commit_comment'
)
);
}
public
function
testForPayload
()
{
$this
->
assertInstanceOf
(
'Nasqueron
\N
otifications
\A
nalyzers
\G
itHub
\E
vents
\C
ommitCommentEvent'
,
Event
::
forPayload
(
'commit_comment'
,
new
\stdClass
)
);
}
public
function
testForPayloadWithException
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
Event
::
forPayload
(
'not_existing'
,
new
\stdClass
);
}
public
function
testCut
()
{
$this
->
assertSame
(
''
,
Event
::
cut
(
''
));
$this
->
assertSame
(
''
,
Event
::
cut
(
''
,
0
));
$this
->
assertSame
(
'…'
,
Event
::
cut
(
'Lorem ipsum dolor'
,
0
));
$this
->
assertSame
(
'Lorem…'
,
Event
::
cut
(
'Lorem ipsum dolor'
,
6
));
$this
->
assertSame
(
'Lorem ipsum dolor'
,
Event
::
cut
(
'Lorem ipsum dolor'
));
}
/**
* @dataProvider payloadDescriptionProvider
*/
public
function
testGetDescriptionAndLink
(
$eventName
,
$expectedDescription
,
$expectedLink
)
{
$filename
=
__DIR__
.
"/../../../data/payloads/GitHubEvents/$eventName.json"
;
$payload
=
json_decode
(
file_get_contents
(
$filename
));
$event
=
Event
::
forPayload
(
$eventName
,
$payload
);
$this
->
assertSame
(
$expectedDescription
,
$event
->
getDescription
());
$this
->
assertSame
(
$expectedLink
,
$event
->
getLink
());
}
public
function
payloadDescriptionProvider
()
{
return
[
'CommitCommentEvent'
=>
[
'commit_comment'
,
'baxterthehacker added a comment to 9049f126: This is a really good change! :+1:'
,
'https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394'
],
'CreateEvent'
=>
[
'create'
,
'New tag on baxterthehacker/public-repo: 0.0.1'
,
'https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1'
],
'DeleteEvent'
=>
[
'delete'
,
'Removed tag on baxterthehacker/public-repo: simple-tag'
,
'https://github.com/baxterthehacker/public-repo/tags'
],
'IssueCommentEvent'
=>
[
'issue_comment'
,
"baxterthehacker added a comment to issue #2 — Spelling error in the README file: You are totally right! I'll get this fixed right away."
,
'https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140'
],
'ForkEvent'
=>
[
'fork'
,
'baxterthehacker/public-repo has been forked to baxterandthehackers/public-repo'
,
'https://github.com/baxterandthehackers/public-repo'
],
'PullRequestEvent'
=>
[
'pull_request'
,
'baxterthehacker has opened a pull request: #1 — Update the README with new information'
,
'https://github.com/baxterthehacker/public-repo/pull/1'
],
'PushEvent'
=>
[
'push'
,
'baxterthehacker committed Update README.md'
,
'https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c'
],
'RepositoryEvent'
=>
[
'repository'
,
'New repository baxterandthehackers/new-repository'
,
'https://github.com/baxterandthehackers/new-repository'
],
'StatusEvent'
=>
[
'status'
,
'Status of 9049f126: default — success'
,
''
],
'WatchEvent'
=>
[
'watch'
,
'baxterthehacker starred baxterthehacker/public-repo'
,
'https://github.com/baxterthehacker'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 11, 20:05 (28 m, 56 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3063874
Default Alt Text
EventTest.php (4 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment