コード例 #1
0
 public function testHandleIssueClosed()
 {
     $g = new WebhookHandler($this->container);
     $p = new ProjectModel($this->container);
     $tc = new TaskCreationModel($this->container);
     $tf = new TaskFinderModel($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $g->setProjectId(1);
     $this->container['dispatcher']->addListener(WebhookHandler::EVENT_ISSUE_CLOSED, array($this, 'onClose'));
     $event = json_decode(file_get_contents(__DIR__ . '/fixtures/gitlab_issue_closed.json'), true);
     // Issue not there
     $this->assertFalse($g->handleIssueClosed($event['object_attributes']));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertEmpty($called);
     // Create a task with the issue reference
     $this->assertEquals(1, $tc->create(array('title' => 'A', 'project_id' => 1, 'reference' => 1268888)));
     $task = $tf->getByReference(1, 1268888);
     $this->assertNotEmpty($task);
     $task = $tf->getByReference(2, 1268888);
     $this->assertEmpty($task);
     $this->assertTrue($g->handleIssueClosed($event['object_attributes']));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(WebhookHandler::EVENT_ISSUE_CLOSED . '.WebhookHandlerTest::onClose', $called);
 }