Пример #1
0
 public function testPush()
 {
     $this->container['dispatcher']->addListener(GithubWebhook::EVENT_COMMIT, array($this, 'onPush'));
     $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', 'project_id' => 1)));
     $g = new GithubWebhook($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload('push', json_decode(file_get_contents(__DIR__ . '/../fixtures/github_push.json'), true)));
 }
Пример #2
0
 public function testMultipleActions()
 {
     $tp = new TaskPosition($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $b = new Board($this->container);
     $p = new Project($this->container);
     $a = new Action($this->container);
     $g = new GithubWebhook($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'unit_test')));
     // We create a new action
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_OPENED, 'action_name' => 'TaskCreation', 'params' => array())));
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_LABEL_CHANGE, 'action_name' => 'TaskAssignCategoryLabel', 'params' => array('label' => 'bug', 'category_id' => 1))));
     $this->assertEquals(3, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'red', 'category_id' => 1))));
     // We attach events
     $a->attachEvents();
     $g->setProjectId(1);
     // We create a Github issue
     $issue = array('number' => 123, 'title' => 'Bugs everywhere', 'body' => 'There is a bug!', 'html_url' => 'http://localhost/');
     $this->assertTrue($g->handleIssueOpened($issue));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(0, $task['category_id']);
     $this->assertEquals('yellow', $task['color_id']);
     // We assign a label to our issue
     $label = array('name' => 'bug');
     $this->assertTrue($g->handleIssueLabeled($issue, $label));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(1, $task['category_id']);
     $this->assertEquals('red', $task['color_id']);
 }