Exemplo n.º 1
0
 public function testParsePayload()
 {
     $g = new BitbucketWebhook($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_COMMIT, function () {
     });
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $g->setProjectId(1);
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertEquals(2, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $event = json_decode($this->post_payload, true);
     $this->assertTrue($g->parsePayload($event));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(BitbucketWebhook::EVENT_COMMIT . '.closure', $called);
 }
Exemplo n.º 2
0
 public function testIssueAssignedWithNoTask()
 {
     $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function () {
     });
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'foobar')));
     $tc = new TaskCreation($this->container);
     $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 43, 'project_id' => 1)));
     $g = new BitbucketWebhook($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());
 }