public function testWithNoComment() { $userModel = new User($this->container); $projectModel = new Project($this->container); $projectUserRoleModel = new ProjectUserRole($this->container); $commentModel = new Comment($this->container); $taskCreationModel = new TaskCreation($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1)); $action = new CommentCreation($this->container); $action->setProjectId(1); $action->addEvent('test.event', 'Test Event'); $this->assertFalse($action->execute($event, 'test.event')); }
public function testWithNoUser() { $action = new CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT); // We create a task in the first column $tc = new TaskCreation($this->container); $p = new Project($this->container); $c = new Comment($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1))); // We create an event to move the task to the 2nd column $event = array('project_id' => 1, 'task_id' => 1, 'user_id' => 0, 'comment' => 'youpi'); // Our event should be executed $this->assertTrue($action->execute(new GenericEvent($event))); $comment = $c->getById(1); $this->assertNotEmpty($comment); $this->assertEquals(1, $comment['task_id']); $this->assertEquals(0, $comment['user_id']); $this->assertEquals('youpi', $comment['comment']); }