summaryrefslogtreecommitdiff
path: root/tests/units/Integration/GitlabWebhookTest.php
diff options
context:
space:
mode:
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();