コード例 #1
0
 public function testHandlePush()
 {
     $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_COMMIT, array($this, 'onCommit'));
     $tc = new TaskCreation($this->container);
     $p = new Project($this->container);
     $bw = new BitbucketWebhook($this->container);
     $payload = json_decode(file_get_contents(__DIR__ . '/../fixtures/bitbucket_push.json'), true);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $bw->setProjectId(1);
     // No task
     $this->assertFalse($bw->handlePush($payload));
     // Create task with the wrong id
     $this->assertEquals(1, $tc->create(array('title' => 'test1', 'project_id' => 1)));
     $this->assertFalse($bw->handlePush($payload));
     // Create task with the right id
     $this->assertEquals(2, $tc->create(array('title' => 'test2', 'project_id' => 1)));
     $this->assertTrue($bw->handlePush($payload));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(BitbucketWebhook::EVENT_COMMIT . '.BitbucketWebhookTest::onCommit', $called);
 }