Пример #1
0
 public function testHandleCommit()
 {
     $g = new GitlabWebhook($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $g->setProjectId(1);
     $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_COMMIT, array($this, 'onCommit'));
     $event = json_decode(file_get_contents(__DIR__ . '/fixtures/gitlab_push.json'), true);
     // No task
     $this->assertFalse($g->handleCommit($event['commits'][0]));
     // Create task with the wrong id
     $this->assertEquals(1, $tc->create(array('title' => 'test1', 'project_id' => 1)));
     $this->assertFalse($g->handleCommit($event['commits'][0]));
     // Create task with the right id
     $this->assertEquals(2, $tc->create(array('title' => 'test2', 'project_id' => 1)));
     $this->assertTrue($g->handleCommit($event['commits'][0]));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(GitlabWebhook::EVENT_COMMIT . '.GitlabWebhookTest::onCommit', $called);
 }
Пример #2
0
 public function testHandleCommit()
 {
     $g = new GitlabWebhook($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $g->setProjectId(1);
     $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_COMMIT, function () {
     });
     $event = json_decode($this->push_payload, true);
     // No task
     $this->assertFalse($g->handleCommit($event['commits'][0]));
     // Create task with the wrong id
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertFalse($g->handleCommit($event['commits'][0]));
     // Create task with the right id
     $this->assertEquals(2, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertTrue($g->handleCommit($event['commits'][0]));
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(GitlabWebhook::EVENT_COMMIT . '.closure', $called);
 }