本文整理汇总了PHP中Kanboard\Model\Project::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::create方法的具体用法?PHP Project::create怎么用?PHP Project::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kanboard\Model\Project
的用法示例。
在下文中一共展示了Project::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDuplicate
public function testDuplicate()
{
$userModel = new User($this->container);
$projectModel = new Project($this->container);
$groupModel = new Group($this->container);
$groupMemberModel = new GroupMember($this->container);
$groupRoleModel = new ProjectGroupRole($this->container);
$userRoleModel = new ProjectUserRole($this->container);
$projectPermission = new ProjectPermission($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Project 1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'Project 2')));
$this->assertEquals(2, $userModel->create(array('username' => 'user 1', 'name' => 'User #1')));
$this->assertEquals(3, $userModel->create(array('username' => 'user 2')));
$this->assertEquals(4, $userModel->create(array('username' => 'user 3')));
$this->assertEquals(5, $userModel->create(array('username' => 'user 4')));
$this->assertEquals(6, $userModel->create(array('username' => 'user 5', 'name' => 'User #5')));
$this->assertEquals(1, $groupModel->create('Group C'));
$this->assertEquals(2, $groupModel->create('Group B'));
$this->assertEquals(3, $groupModel->create('Group A'));
$this->assertTrue($groupMemberModel->addUser(1, 4));
$this->assertTrue($groupMemberModel->addUser(2, 5));
$this->assertTrue($groupMemberModel->addUser(3, 3));
$this->assertTrue($groupMemberModel->addUser(3, 2));
$this->assertTrue($groupRoleModel->addGroup(1, 1, Role::PROJECT_VIEWER));
$this->assertTrue($groupRoleModel->addGroup(1, 3, Role::PROJECT_MANAGER));
$this->assertTrue($userRoleModel->addUser(1, 5, Role::PROJECT_MANAGER));
$this->assertTrue($userRoleModel->addUser(1, 6, Role::PROJECT_MEMBER));
$this->assertTrue($projectPermission->duplicate(1, 2));
$this->assertCount(2, $userRoleModel->getUsers(2));
$this->assertCount(3, $groupRoleModel->getUsers(2));
}
示例2: testHandlePayload
public function testHandlePayload()
{
$w = new EmailHandler($this->container);
$p = new Project($this->container);
$pp = new ProjectUserRole($this->container);
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
// Empty payload
$this->assertFalse($w->receiveEmail(array()));
// Unknown user
$this->assertFalse($w->receiveEmail(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
// Project not found
$this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
// User is not member
$this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
$this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
// The task must be created
$this->assertTrue($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-html' => '<strong>boo</strong>')));
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**boo**', $task['description']);
$this->assertEquals(2, $task['creator_id']);
}
示例3: testExecute
public function testExecute()
{
$action = new TaskMoveAnotherProject($this->container, 1, Task::EVENT_MOVE_COLUMN);
// We create a task in the first column
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
$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, 'column_id' => 2);
// Our event should NOT be executed because we define the same project
$action->setParam('column_id', 2);
$action->setParam('project_id', 1);
$this->assertFalse($action->execute(new GenericEvent($event)));
// Our task should be assigned to the project 1
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
// We create an event to move the task to the 2nd column
$event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
// Our event should be executed because we define a different project
$action->setParam('column_id', 2);
$action->setParam('project_id', 2);
$this->assertTrue($action->execute(new GenericEvent($event)));
// Our task should be assigned to the project 2
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
}
示例4: testBuildWithNoTasks
public function testBuildWithNoTasks()
{
$taskCreationModel = new TaskCreation($this->container);
$projectModel = new Project($this->container);
$averageLeadCycleTimeAnalytic = new AverageLeadCycleTimeAnalytic($this->container);
$now = time();
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test1')));
$stats = $averageLeadCycleTimeAnalytic->build(1);
$expected = array('count' => 0, 'total_lead_time' => 0, 'total_cycle_time' => 0, 'avg_lead_time' => 0, 'avg_cycle_time' => 0);
$this->assertEquals($expected, $stats);
}
示例5: testBuild
public function testBuild()
{
$projectModel = new Project($this->container);
$taskDistributionModel = new TaskDistributionAnalytic($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test1')));
$this->createTasks(1, 20, 1);
$this->createTasks(2, 30, 1);
$this->createTasks(3, 40, 1);
$this->createTasks(4, 10, 1);
$expected = array(array('column_title' => 'Backlog', 'nb_tasks' => 20, 'percentage' => 20.0), array('column_title' => 'Ready', 'nb_tasks' => 30, 'percentage' => 30.0), array('column_title' => 'Work in progress', 'nb_tasks' => 40, 'percentage' => 40.0), array('column_title' => 'Done', 'nb_tasks' => 10, 'percentage' => 10.0));
$this->assertEquals($expected, $taskDistributionModel->build(1));
}
示例6: testWithWrongColumn
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'column_id' => 3, 'owner_id' => 1));
$action = new TaskMoveColumnAssigned($this->container);
$action->setProjectId(1);
$action->setParam('src_column_id', 1);
$action->setParam('dest_column_id', 2);
$this->assertFalse($action->execute($event, Task::EVENT_ASSIGNEE_CHANGE));
}
示例7: testCountByProject
public function testCountByProject()
{
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(2, $p->create(array('name' => 'Project #2')));
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2)));
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 2)));
$this->assertEquals(1, $tf->countByProjectId(1));
$this->assertEquals(2, $tf->countByProjectId(2));
}
示例8: testWithWrongColumn
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'column_id' => 3));
$action = new TaskMoveAnotherProject($this->container);
$action->setProjectId(1);
$action->setParam('project_id', 2);
$action->setParam('column_id', 2);
$this->assertFalse($action->execute($event, Task::EVENT_CLOSE));
}
示例9: testBuildWithOnlyClosedTask
public function testBuildWithOnlyClosedTask()
{
$taskCreationModel = new TaskCreation($this->container);
$projectModel = new Project($this->container);
$estimatedTimeComparisonAnalytic = new EstimatedTimeComparisonAnalytic($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test1')));
$this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'time_estimated' => 5.5, 'is_active' => 0)));
$this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'time_estimated' => 1.75, 'is_active' => 0)));
$this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'time_spent' => 8.25, 'is_active' => 0)));
$this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'time_spent' => 0.25, 'is_active' => 0)));
$expected = array('closed' => array('time_spent' => 8.5, 'time_estimated' => 7.25), 'open' => array('time_spent' => 0, 'time_estimated' => 0));
$this->assertEquals($expected, $estimatedTimeComparisonAnalytic->build(1));
}
示例10: testExecute
public function testExecute()
{
$action = new TaskMoveColumnCategoryChange($this->container, 1, Task::EVENT_UPDATE);
$action->setParam('dest_column_id', 3);
$action->setParam('category_id', 1);
$this->assertEquals(3, $action->getParam('dest_column_id'));
$this->assertEquals(1, $action->getParam('category_id'));
// We create a task in the first column
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $c->create(array('name' => 'bug', 'project_id' => 1)));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
// No category should be assigned + column_id=1
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEmpty($task['category_id']);
$this->assertEquals(1, $task['column_id']);
// We create an event to move the task to the 2nd column
$event = array('task_id' => 1, 'column_id' => 1, 'project_id' => 1, 'category_id' => 1);
// Our event should be executed
$this->assertTrue($action->hasCompatibleEvent());
$this->assertTrue($action->hasRequiredProject($event));
$this->assertTrue($action->hasRequiredParameters($event));
$this->assertTrue($action->hasRequiredCondition($event));
$this->assertTrue($action->isExecutable($event));
$this->assertTrue($action->execute(new GenericEvent($event)));
// Our task should be moved to the other column
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(3, $task['column_id']);
}
示例11: testExecute
public function testExecute()
{
$action = new TaskAssignColorUser($this->container, 1, Task::EVENT_ASSIGNEE_CHANGE);
$action->setParam('user_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
// We change the assignee
$event = array('project_id' => 1, 'task_id' => 1, 'owner_id' => 5);
// Our event should NOT be executed
$this->assertFalse($action->execute(new GenericEvent($event)));
// Our task should be assigned to nobody and have the green color
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals('green', $task['color_id']);
// We change the assignee
$event = array('project_id' => 1, 'task_id' => 1, 'owner_id' => 1);
// Our event should be executed
$this->assertTrue($action->execute(new GenericEvent($event)));
// Our task should be assigned to nobody and have the blue color
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals('blue', $task['color_id']);
}
示例12: testGetAggregatedMetrics
public function testGetAggregatedMetrics()
{
$projectModel = new Project($this->container);
$projectDailyColumnStats = new ProjectDailyColumnStats($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
$this->createTasks(1, 2, 1);
$this->createTasks(1, 3, 0);
$this->createTasks(2, 5, 1);
$this->createTasks(2, 8, 1);
$this->createTasks(2, 0, 0);
$this->createTasks(2, 0, 0);
$projectDailyColumnStats->updateTotals(1, '2016-01-16');
$this->createTasks(1, 9, 1);
$this->createTasks(1, 7, 0);
$projectDailyColumnStats->updateTotals(1, '2016-01-16');
$this->createTasks(3, 0, 1);
$projectDailyColumnStats->updateTotals(1, '2016-01-17');
$this->createTasks(2, 1, 1);
$this->createTasks(3, 1, 1);
$this->createTasks(3, 0, 1);
$projectDailyColumnStats->updateTotals(1, '2016-01-18');
$expected = array(array('Date', 'Backlog', 'Ready', 'Work in progress', 'Done'), array('2016-01-16', 4, 4, 0, 0), array('2016-01-17', 4, 4, 1, 0), array('2016-01-18', 4, 5, 3, 0));
$this->assertEquals($expected, $projectDailyColumnStats->getAggregatedMetrics(1, '2016-01-16', '2016-01-18'));
$expected = array(array('Date', 'Backlog', 'Ready', 'Work in progress', 'Done'), array('2016-01-16', 11, 13, 0, 0), array('2016-01-17', 11, 13, 0, 0), array('2016-01-18', 11, 14, 1, 0));
$this->assertEquals($expected, $projectDailyColumnStats->getAggregatedMetrics(1, '2016-01-16', '2016-01-18', 'score'));
}
示例13: testExecute
public function testExecute()
{
$action = new TaskAssignColorCategory($this->container, 1, Task::EVENT_CREATE_UPDATE);
$action->setParam('category_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $c->create(array('name' => 'c1', 'project_id' => 1)));
$this->assertEquals(2, $c->create(array('name' => 'c2', 'project_id' => 1)));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
// We create an event but we don't do anything
$event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'category_id' => 2, 'position' => 2);
// Our event should NOT be executed
$this->assertFalse($action->execute(new GenericEvent($event)));
// Our task should be assigned to the ategory_id=1 and have the green color
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['category_id']);
$this->assertEquals('green', $task['color_id']);
// We create an event to move the task
$event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'position' => 5, 'category_id' => 1);
// Our event should be executed
$this->assertTrue($action->execute(new GenericEvent($event)));
// Our task should have the blue color
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals('blue', $task['color_id']);
}
示例14: testUpdateTotals
public function testUpdateTotals()
{
$p = new Project($this->container);
$pds = new ProjectDailyColumnStats($this->container);
$tc = new TaskCreation($this->container);
$ts = new TaskStatus($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertEquals(0, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')));
for ($i = 0; $i < 10; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 1)));
}
for ($i = 0; $i < 5; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4)));
}
$pds->updateTotals(1, date('Y-m-d', strtotime('-2days')));
for ($i = 0; $i < 15; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3)));
}
for ($i = 0; $i < 25; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2)));
}
$pds->updateTotals(1, date('Y-m-d', strtotime('-1 day')));
$this->assertNotFalse($ts->close(1));
$this->assertNotFalse($ts->close(2));
for ($i = 0; $i < 3; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 3)));
}
for ($i = 0; $i < 5; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 2)));
}
for ($i = 0; $i < 4; $i++) {
$this->assertNotFalse($tc->create(array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 4)));
}
$pds->updateTotals(1, date('Y-m-d'));
$this->assertEquals(3, $pds->countDays(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d')));
$metrics = $pds->getAggregatedMetrics(1, date('Y-m-d', strtotime('-2days')), date('Y-m-d'));
$this->assertNotEmpty($metrics);
$this->assertEquals(4, count($metrics));
$this->assertEquals(5, count($metrics[0]));
$this->assertEquals('Date', $metrics[0][0]);
$this->assertEquals('Backlog', $metrics[0][1]);
$this->assertEquals('Ready', $metrics[0][2]);
$this->assertEquals('Work in progress', $metrics[0][3]);
$this->assertEquals('Done', $metrics[0][4]);
$this->assertEquals(date('Y-m-d', strtotime('-2days')), $metrics[1][0]);
$this->assertEquals(10, $metrics[1][1]);
$this->assertEquals(0, $metrics[1][2]);
$this->assertEquals(0, $metrics[1][3]);
$this->assertEquals(5, $metrics[1][4]);
$this->assertEquals(date('Y-m-d', strtotime('-1day')), $metrics[2][0]);
$this->assertEquals(10, $metrics[2][1]);
$this->assertEquals(25, $metrics[2][2]);
$this->assertEquals(15, $metrics[2][3]);
$this->assertEquals(5, $metrics[2][4]);
$this->assertEquals(date('Y-m-d'), $metrics[3][0]);
$this->assertEquals(10, $metrics[3][1]);
$this->assertEquals(30, $metrics[3][2]);
$this->assertEquals(18, $metrics[3][3]);
$this->assertEquals(9, $metrics[3][4]);
}
示例15: testAverageWithTransitions
public function testAverageWithTransitions()
{
$transitionModel = new Transition($this->container);
$taskFinderModel = new TaskFinder($this->container);
$taskCreationModel = new TaskCreation($this->container);
$projectModel = new Project($this->container);
$averageLeadCycleTimeAnalytic = new AverageTimeSpentColumnAnalytic($this->container);
$now = time();
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
$this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
$this->container['db']->table(Task::TABLE)->eq('id', 1)->update(array('date_completed' => $now + 3600));
$this->container['db']->table(Task::TABLE)->eq('id', 2)->update(array('date_completed' => $now + 1800));
foreach (array(1, 2) as $task_id) {
$task = $taskFinderModel->getById($task_id);
$task['task_id'] = $task['id'];
$task['date_moved'] = $now - 900;
$task['src_column_id'] = 3;
$task['dst_column_id'] = 1;
$this->assertTrue($transitionModel->save(1, $task));
}
$stats = $averageLeadCycleTimeAnalytic->build(1);
$expected = array(1 => array('count' => 2, 'time_spent' => 3600 + 1800, 'average' => (int) ((3600 + 1800) / 2), 'title' => 'Backlog'), 2 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Ready'), 3 => array('count' => 2, 'time_spent' => 1800, 'average' => 900, 'title' => 'Work in progress'), 4 => array('count' => 0, 'time_spent' => 0, 'average' => 0, 'title' => 'Done'));
$this->assertEquals($expected, $stats);
}