summaryrefslogtreecommitdiff
path: root/tests/units/Integration/GitlabWebhookTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-04 21:28:11 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-04 21:28:11 -0500
commit3925cf68dd117522058a43f5dacc45b28a7781ed (patch)
treefbfe483fbac096b1aabfccf2e2437f9ce83a62b4 /tests/units/Integration/GitlabWebhookTest.php
parent1250e745e43385b421af6ce226fcca5616336b70 (diff)
parent207ee05b0ef2d084489d5b01c071b68a4f5075ca (diff)
Merge pull-request #1523
Diffstat (limited to 'tests/units/Integration/GitlabWebhookTest.php')
-rw-r--r--tests/units/Integration/GitlabWebhookTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/units/Integration/GitlabWebhookTest.php b/tests/units/Integration/GitlabWebhookTest.php
index 6d37819b..fa05f292 100644
--- a/tests/units/Integration/GitlabWebhookTest.php
+++ b/tests/units/Integration/GitlabWebhookTest.php
@@ -64,6 +64,35 @@ class GitlabWebhookTest extends Base
$this->assertArrayHasKey(GitlabWebhook::EVENT_ISSUE_OPENED.'.GitlabWebhookTest::onOpen', $called);
}
+ public function testHandleIssueReopened()
+ {
+ $g = new GitlabWebhook($this->container);
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $g->setProjectId(1);
+
+ $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_REOPENED, array($this, 'onReopen'));
+
+ $event = json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_issue_reopened.json'), true);
+
+ // Issue not there
+ $this->assertFalse($g->handleIssueReopened($event['object_attributes']));
+
+ $called = $this->container['dispatcher']->getCalledListeners();
+ $this->assertEmpty($called);
+
+ $this->assertEquals(1, $tc->create(array('title' => 'A', 'project_id' => 1, 'reference' => 355691)));
+ $task = $tf->getByReference(1, 355691);
+ $this->assertTrue($g->handleIssueReopened($event['object_attributes']));
+
+ $called = $this->container['dispatcher']->getCalledListeners();
+ $this->assertArrayHasKey(GitlabWebhook::EVENT_ISSUE_REOPENED.'.GitlabWebhookTest::onReopen', $called);
+ }
+
+
public function testHandleIssueClosed()
{
$g = new GitlabWebhook($this->container);
@@ -170,6 +199,13 @@ class GitlabWebhookTest extends Base
$this->assertEquals("There is a bug somewhere.\r\n\r\nBye\n\n[Gitlab Issue](https://gitlab.com/minicoders/test-webhook/issues/1)", $data['description']);
}
+ public function onReopen($event)
+ {
+ $data = $event->getAll();
+ $this->assertEquals(1, $data['project_id']);
+ $this->assertEquals(1, $data['task_id']);
+ $this->assertEquals(355691, $data['reference']);
+ }
public function onClose($event)
{
$data = $event->getAll();