Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792741
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/app/Analyzers/GitHub/Events/ForkEvent.php b/app/Analyzers/GitHub/Events/ForkEvent.php
new file mode 100644
index 0000000..06b6a9f
--- /dev/null
+++ b/app/Analyzers/GitHub/Events/ForkEvent.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Nasqueron\Notifications\Analyzers\GitHub\Events;
+
+/**
+ * ForkEvent payload analyzer
+ *
+ * Triggered when a repository is forked.
+ *
+ * @link https://developer.github.com/v3/activity/events/types/#forkevent
+ */
+class ForkEvent extends Event {
+
+ /**
+ * Gets description for the payload
+ *
+ * @return string
+ */
+ public function getDescription () {
+ return trans(
+ 'GitHub.EventsDescriptions.ForkEvent',
+ [
+ 'repo_base' => $this->payload->repository->full_name,
+ 'repo_fork' => $this->payload->forkee->full_name,
+ ]
+ );
+ }
+
+ /**
+ * Gets link for the payload
+ *
+ * @return string
+ */
+ public function getLink () {
+ return $this->payload->forkee->html_url;
+ }
+}
diff --git a/resources/lang/en/GitHub.php b/resources/lang/en/GitHub.php
index 8ecaade..66433b8 100644
--- a/resources/lang/en/GitHub.php
+++ b/resources/lang/en/GitHub.php
@@ -1,53 +1,55 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| GitHub notifications messages
|--------------------------------------------------------------------------
|
| The following language lines are used to localize notifications for events
| fired by GitHub
|
*/
'Separator' => ' — ',
'Commits' => [
'Message' => ':committer committed :title',
'Authored' => ' (authored by :author)', // appended to Message
],
'RepoAndBranch' => ':repo (branch :branch)',
'EventsDescriptions' => [
'CommitCommentEvent' => ':author added a comment to :commit: :excerpt',
'CreateEvent' => 'New :type on :repository: :ref',
'CreateEventUnknown' => 'Unknown create reference: :type :ref',
'DeleteEvent' => 'Removed :type on :repository: :ref',
'DeleteEventUnknown' => 'Unknown delete reference: :type :ref',
+ 'ForkEvent' => ':repo_base has been forked to :repo_fork',
+
'PingEvent' => '« :zen » — GitHub Webhooks ping zen aphorism.',
'PushEvent' => [
'0' => ':user forcely updated :repoAndBranch',
'n' => ':user pushed :count commits to :repoAndBranch', // n > 1
],
'RepositoryEvent' => 'New repository :repository',
'RepositoryEventFork' => ' (fork)',
'StatusEvent' => 'Status of :commit: :status',
],
'StatusEventState' => [
'pending' => 'pending',
'success' => 'success',
'failure' => 'failure',
'error' => 'error',
],
];
diff --git a/tests/Analyzers/GitHub/Events/EventTest.php b/tests/Analyzers/GitHub/Events/EventTest.php
index 36117b6..c536d95 100644
--- a/tests/Analyzers/GitHub/Events/EventTest.php
+++ b/tests/Analyzers/GitHub/Events/EventTest.php
@@ -1,88 +1,93 @@
<?php
namespace Nasqueron\Notifications\Tests\Analyzers\GitHub\Events;
use Nasqueron\Notifications\Analyzers\GitHub\Events\Event;
use Nasqueron\Notifications\Tests\TestCase;
class EventTest extends TestCase {
public function testGetClass () {
$this->assertSame(
'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent',
Event::getClass('commit_comment')
);
}
public function testForPayload () {
$this->assertInstanceOf(
'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent',
Event::forPayload('commit_comment', new \stdClass)
);
}
/**
* @expectedException InvalidArgumentException
*/
public function testForPayloadWithException () {
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'
],
+ 'ForkEvent' => [
+ 'fork',
+ 'baxterthehacker/public-repo has been forked to baxterandthehackers/public-repo',
+ 'https://github.com/baxterandthehackers/public-repo'
+ ],
'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',
''
],
];
}
}
diff --git a/tests/data/payloads/GitHubEvents/fork.json b/tests/data/payloads/GitHubEvents/fork.json
new file mode 100644
index 0000000..e01d3c5
--- /dev/null
+++ b/tests/data/payloads/GitHubEvents/fork.json
@@ -0,0 +1,196 @@
+{
+ "forkee": {
+ "id": 35129393,
+ "name": "public-repo",
+ "full_name": "baxterandthehackers/public-repo",
+ "owner": {
+ "login": "baxterandthehackers",
+ "id": 7649605,
+ "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/baxterandthehackers",
+ "html_url": "https://github.com/baxterandthehackers",
+ "followers_url": "https://api.github.com/users/baxterandthehackers/followers",
+ "following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}",
+ "gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions",
+ "organizations_url": "https://api.github.com/users/baxterandthehackers/orgs",
+ "repos_url": "https://api.github.com/users/baxterandthehackers/repos",
+ "events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/baxterandthehackers/received_events",
+ "type": "Organization",
+ "site_admin": false
+ },
+ "private": false,
+ "html_url": "https://github.com/baxterandthehackers/public-repo",
+ "description": "",
+ "fork": true,
+ "url": "https://api.github.com/repos/baxterandthehackers/public-repo",
+ "forks_url": "https://api.github.com/repos/baxterandthehackers/public-repo/forks",
+ "keys_url": "https://api.github.com/repos/baxterandthehackers/public-repo/keys{/key_id}",
+ "collaborators_url": "https://api.github.com/repos/baxterandthehackers/public-repo/collaborators{/collaborator}",
+ "teams_url": "https://api.github.com/repos/baxterandthehackers/public-repo/teams",
+ "hooks_url": "https://api.github.com/repos/baxterandthehackers/public-repo/hooks",
+ "issue_events_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues/events{/number}",
+ "events_url": "https://api.github.com/repos/baxterandthehackers/public-repo/events",
+ "assignees_url": "https://api.github.com/repos/baxterandthehackers/public-repo/assignees{/user}",
+ "branches_url": "https://api.github.com/repos/baxterandthehackers/public-repo/branches{/branch}",
+ "tags_url": "https://api.github.com/repos/baxterandthehackers/public-repo/tags",
+ "blobs_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/blobs{/sha}",
+ "git_tags_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/tags{/sha}",
+ "git_refs_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/refs{/sha}",
+ "trees_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/trees{/sha}",
+ "statuses_url": "https://api.github.com/repos/baxterandthehackers/public-repo/statuses/{sha}",
+ "languages_url": "https://api.github.com/repos/baxterandthehackers/public-repo/languages",
+ "stargazers_url": "https://api.github.com/repos/baxterandthehackers/public-repo/stargazers",
+ "contributors_url": "https://api.github.com/repos/baxterandthehackers/public-repo/contributors",
+ "subscribers_url": "https://api.github.com/repos/baxterandthehackers/public-repo/subscribers",
+ "subscription_url": "https://api.github.com/repos/baxterandthehackers/public-repo/subscription",
+ "commits_url": "https://api.github.com/repos/baxterandthehackers/public-repo/commits{/sha}",
+ "git_commits_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/commits{/sha}",
+ "comments_url": "https://api.github.com/repos/baxterandthehackers/public-repo/comments{/number}",
+ "issue_comment_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues/comments{/number}",
+ "contents_url": "https://api.github.com/repos/baxterandthehackers/public-repo/contents/{+path}",
+ "compare_url": "https://api.github.com/repos/baxterandthehackers/public-repo/compare/{base}...{head}",
+ "merges_url": "https://api.github.com/repos/baxterandthehackers/public-repo/merges",
+ "archive_url": "https://api.github.com/repos/baxterandthehackers/public-repo/{archive_format}{/ref}",
+ "downloads_url": "https://api.github.com/repos/baxterandthehackers/public-repo/downloads",
+ "issues_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues{/number}",
+ "pulls_url": "https://api.github.com/repos/baxterandthehackers/public-repo/pulls{/number}",
+ "milestones_url": "https://api.github.com/repos/baxterandthehackers/public-repo/milestones{/number}",
+ "notifications_url": "https://api.github.com/repos/baxterandthehackers/public-repo/notifications{?since,all,participating}",
+ "labels_url": "https://api.github.com/repos/baxterandthehackers/public-repo/labels{/name}",
+ "releases_url": "https://api.github.com/repos/baxterandthehackers/public-repo/releases{/id}",
+ "created_at": "2015-05-05T23:40:30Z",
+ "updated_at": "2015-05-05T23:40:30Z",
+ "pushed_at": "2015-05-05T23:40:27Z",
+ "git_url": "git://github.com/baxterandthehackers/public-repo.git",
+ "ssh_url": "git@github.com:baxterandthehackers/public-repo.git",
+ "clone_url": "https://github.com/baxterandthehackers/public-repo.git",
+ "svn_url": "https://github.com/baxterandthehackers/public-repo",
+ "homepage": null,
+ "size": 0,
+ "stargazers_count": 0,
+ "watchers_count": 0,
+ "language": null,
+ "has_issues": false,
+ "has_downloads": true,
+ "has_wiki": true,
+ "has_pages": true,
+ "forks_count": 0,
+ "mirror_url": null,
+ "open_issues_count": 0,
+ "forks": 0,
+ "open_issues": 0,
+ "watchers": 0,
+ "default_branch": "master",
+ "public": true
+ },
+ "repository": {
+ "id": 35129377,
+ "name": "public-repo",
+ "full_name": "baxterthehacker/public-repo",
+ "owner": {
+ "login": "baxterthehacker",
+ "id": 6752317,
+ "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/baxterthehacker",
+ "html_url": "https://github.com/baxterthehacker",
+ "followers_url": "https://api.github.com/users/baxterthehacker/followers",
+ "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
+ "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
+ "organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
+ "repos_url": "https://api.github.com/users/baxterthehacker/repos",
+ "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
+ "type": "User",
+ "site_admin": false
+ },
+ "private": false,
+ "html_url": "https://github.com/baxterthehacker/public-repo",
+ "description": "",
+ "fork": false,
+ "url": "https://api.github.com/repos/baxterthehacker/public-repo",
+ "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
+ "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
+ "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
+ "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
+ "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
+ "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
+ "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
+ "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
+ "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
+ "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
+ "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
+ "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
+ "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
+ "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
+ "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
+ "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
+ "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
+ "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
+ "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
+ "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
+ "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
+ "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
+ "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
+ "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
+ "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
+ "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
+ "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
+ "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
+ "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
+ "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
+ "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
+ "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
+ "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
+ "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
+ "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
+ "created_at": "2015-05-05T23:40:12Z",
+ "updated_at": "2015-05-05T23:40:30Z",
+ "pushed_at": "2015-05-05T23:40:27Z",
+ "git_url": "git://github.com/baxterthehacker/public-repo.git",
+ "ssh_url": "git@github.com:baxterthehacker/public-repo.git",
+ "clone_url": "https://github.com/baxterthehacker/public-repo.git",
+ "svn_url": "https://github.com/baxterthehacker/public-repo",
+ "homepage": null,
+ "size": 0,
+ "stargazers_count": 0,
+ "watchers_count": 0,
+ "language": null,
+ "has_issues": true,
+ "has_downloads": true,
+ "has_wiki": true,
+ "has_pages": true,
+ "forks_count": 1,
+ "mirror_url": null,
+ "open_issues_count": 2,
+ "forks": 1,
+ "open_issues": 2,
+ "watchers": 0,
+ "default_branch": "master"
+ },
+ "sender": {
+ "login": "baxterandthehackers",
+ "id": 7649605,
+ "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/baxterandthehackers",
+ "html_url": "https://github.com/baxterandthehackers",
+ "followers_url": "https://api.github.com/users/baxterandthehackers/followers",
+ "following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}",
+ "gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions",
+ "organizations_url": "https://api.github.com/users/baxterandthehackers/orgs",
+ "repos_url": "https://api.github.com/users/baxterandthehackers/repos",
+ "events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/baxterandthehackers/received_events",
+ "type": "Organization",
+ "site_admin": false
+ }
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Feb 28, 20:36 (21 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2447795
Default Alt Text
(19 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment