/**
  * Handle Github webhooks
  *
  * @access public
  */
 public function handler()
 {
     $this->checkWebhookToken();
     $githubWebhook = new WebhookHandler($this->container);
     $githubWebhook->setProjectId($this->request->getIntegerParam('project_id'));
     $result = $githubWebhook->parsePayload($this->request->getHeader('X-Github-Event'), $this->request->getJson());
     $this->response->text($result ? 'PARSED' : 'IGNORED');
 }
 public function testPush()
 {
     $this->container['dispatcher']->addListener(WebhookHandler::EVENT_COMMIT, array($this, 'onPush'));
     $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', 'project_id' => 1)));
     $g = new WebhookHandler($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload('push', json_decode(file_get_contents(__DIR__ . '/fixtures/github_push.json'), true)));
 }