/**
  * Handle Bitbucket webhooks
  *
  * @access public
  */
 public function handler()
 {
     $this->checkWebhookToken();
     $bitbucketWebhook = new WebhookHandler($this->container);
     $bitbucketWebhook->setProjectId($this->request->getIntegerParam('project_id'));
     $result = $bitbucketWebhook->parsePayload($this->request->getHeader('X-Event-Key'), $this->request->getJson());
     $this->response->text($result ? 'PARSED' : 'IGNORED');
 }
 public function testIssueAssignedWithNoTask()
 {
     $this->container['dispatcher']->addListener(WebhookHandler::EVENT_ISSUE_ASSIGNEE_CHANGE, function () {
     });
     $p = new ProjectModel($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'foobar')));
     $tc = new TaskCreationModel($this->container);
     $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 43, 'project_id' => 1)));
     $g = new WebhookHandler($this->container);
     $g->setProjectId(1);
     $this->assertFalse($g->parsePayload('issue:updated', json_decode(file_get_contents(__DIR__ . '/fixtures/bitbucket_issue_assigned.json'), true)));
     $this->assertEmpty($this->container['dispatcher']->getCalledListeners());
 }