當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Project::getById方法代碼示例

本文整理匯總了PHP中Kanboard\Model\Project::getById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Project::getById方法的具體用法?PHP Project::getById怎麽用?PHP Project::getById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Kanboard\Model\Project的用法示例。


在下文中一共展示了Project::getById方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testValidateModification

 public function testValidateModification()
 {
     $validator = new ProjectValidator($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2', 'identifier' => 'TEST2')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST1', $project['identifier']);
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST2', $project['identifier']);
     $r = $validator->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'TEST1'));
     $this->assertTrue($r[0]);
     $r = $validator->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'test3'));
     $this->assertTrue($r[0]);
     $r = $validator->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => ''));
     $this->assertTrue($r[0]);
     $r = $validator->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'TEST2'));
     $this->assertFalse($r[0]);
 }
開發者ID:peripatetic-sojourner,項目名稱:kanboard,代碼行數:21,代碼來源:ProjectValidatorTest.php

示例2: testNotifyProjectWithWebhookNotConfigured

 public function testNotifyProjectWithWebhookNotConfigured()
 {
     $this->container['httpClient']->expects($this->never())->method('postForm');
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $taskFinderModel = new TaskFinder($this->container);
     $handler = new RocketChat($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->container['projectMetadata']->save(1, array('rocketchat_webhook_url' => ''));
     $project = $projectModel->getById(1);
     $task = $taskFinderModel->getDetails(1);
     $event = array('task' => $task);
     $event['task']['task_id'] = $task['id'];
     $handler->notifyProject($project, Task::EVENT_MOVE_COLUMN, $event);
 }
開發者ID:RocketChat,項目名稱:plugin-rocketchat,代碼行數:17,代碼來源:RocketChatTest.php

示例3: testPriority

 public function testPriority()
 {
     $projectModel = new Project($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'My project 2')));
     $project = $projectModel->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals(0, $project['priority_default']);
     $this->assertEquals(0, $project['priority_start']);
     $this->assertEquals(3, $project['priority_end']);
     $this->assertTrue($projectModel->update(array('id' => 1, 'priority_start' => 2, 'priority_end' => 5, 'priority_default' => 4)));
     $project = $projectModel->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals(4, $project['priority_default']);
     $this->assertEquals(2, $project['priority_start']);
     $this->assertEquals(5, $project['priority_end']);
 }
開發者ID:perburn,項目名稱:kanboard,代碼行數:16,代碼來源:ProjectTest.php

示例4: testCloneProjectWithUsers

 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
     $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
     $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($pp->addMember(1, 4));
     $this->assertTrue($pp->addManager(1, 3));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isMember(1, 3));
     $this->assertTrue($pp->isMember(1, 4));
     $this->assertFalse($pp->isManager(1, 2));
     $this->assertTrue($pp->isManager(1, 3));
     $this->assertFalse($pp->isManager(1, 4));
     $this->assertEquals(2, $pd->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $this->assertEquals(3, count($pp->getMembers(2)));
     $this->assertTrue($pp->isMember(2, 2));
     $this->assertTrue($pp->isMember(2, 3));
     $this->assertTrue($pp->isMember(2, 4));
     $this->assertFalse($pp->isManager(2, 2));
     $this->assertTrue($pp->isManager(2, 3));
     $this->assertFalse($pp->isManager(2, 4));
 }
開發者ID:Folcky,項目名稱:kanboard,代碼行數:32,代碼來源:ProjectDuplicationTest.php

示例5: testRemove

 public function testRemove()
 {
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $s = new Subtask($this->container);
     $c = new Comment($this->container);
     $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
     $this->assertEquals(1, $s->create(array('title' => 'Subtask #1', 'user_id' => 2, 'task_id' => 1)));
     $this->assertEquals(1, $c->create(array('comment' => 'foobar', 'user_id' => 2, 'task_id' => 1)));
     $task = $tf->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(2, $task['owner_id']);
     $this->assertTrue($u->remove(1));
     $this->assertTrue($u->remove(2));
     $this->assertFalse($u->remove(2));
     $this->assertFalse($u->remove(55));
     // Make sure that assigned tasks are unassigned after removing the user
     $task = $tf->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(0, $task['owner_id']);
     // Make sure that assigned subtasks are unassigned after removing the user
     $subtask = $s->getById(1);
     $this->assertEquals(1, $subtask['id']);
     $this->assertEquals(0, $subtask['user_id']);
     // Make sure that comments are not related to the user anymore
     $comment = $c->getById(1);
     $this->assertEquals(1, $comment['id']);
     $this->assertEquals(0, $comment['user_id']);
     // Make sure that private projects are also removed
     $user_id1 = $u->create(array('username' => 'toto1', 'password' => '123456', 'name' => 'Toto'));
     $user_id2 = $u->create(array('username' => 'toto2', 'password' => '123456', 'name' => 'Toto'));
     $this->assertNotFalse($user_id1);
     $this->assertNotFalse($user_id2);
     $this->assertEquals(2, $p->create(array('name' => 'Private project #1', 'is_private' => 1), $user_id1, true));
     $this->assertEquals(3, $p->create(array('name' => 'Private project #2', 'is_private' => 1), $user_id2, true));
     $this->assertTrue($u->remove($user_id1));
     $this->assertNotEmpty($p->getById(1));
     $this->assertNotEmpty($p->getById(3));
     $this->assertEmpty($p->getById(2));
 }
開發者ID:perburn,項目名稱:kanboard,代碼行數:44,代碼來源:UserTest.php

示例6: testIdentifier

 public function testIdentifier()
 {
     $p = new Project($this->container);
     // Creation
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST1', $project['identifier']);
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('', $project['identifier']);
     // Update
     $this->assertTrue($p->update(array('id' => '2', 'identifier' => 'test2')));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST2', $project['identifier']);
     $project = $p->getByIdentifier('test1');
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST1', $project['identifier']);
     $project = $p->getByIdentifier('');
     $this->assertFalse($project);
 }
開發者ID:peripatetic-sojourner,項目名稱:kanboard,代碼行數:23,代碼來源:ProjectTest.php

示例7: testIdentifier

 public function testIdentifier()
 {
     $p = new Project($this->container);
     // Creation
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'identifier' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST1', $project['identifier']);
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('', $project['identifier']);
     // Update
     $this->assertTrue($p->update(array('id' => '2', 'identifier' => 'test2')));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST2', $project['identifier']);
     $project = $p->getByIdentifier('test1');
     $this->assertNotEmpty($project);
     $this->assertEquals('TEST1', $project['identifier']);
     $project = $p->getByIdentifier('');
     $this->assertFalse($project);
     // Validation rules
     $r = $p->validateCreation(array('name' => 'test', 'identifier' => 'TEST1'));
     $this->assertFalse($r[0]);
     $r = $p->validateCreation(array('name' => 'test', 'identifier' => 'test1'));
     $this->assertFalse($r[0]);
     $r = $p->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'TEST1'));
     $this->assertTrue($r[0]);
     $r = $p->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'test3'));
     $this->assertTrue($r[0]);
     $r = $p->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => ''));
     $this->assertTrue($r[0]);
     $r = $p->validateModification(array('id' => 1, 'name' => 'test', 'identifier' => 'TEST2'));
     $this->assertFalse($r[0]);
     $r = $p->validateCreation(array('name' => 'test', 'identifier' => 'a-b-c'));
     $this->assertFalse($r[0]);
     $r = $p->validateCreation(array('name' => 'test', 'identifier' => 'test 123'));
     $this->assertFalse($r[0]);
 }
開發者ID:Folcky,項目名稱:kanboard,代碼行數:40,代碼來源:ProjectTest.php

示例8: testCloneProjectWithUsers

 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectUserRole($this->container);
     $u = new User($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
     $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
     $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 3, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 4, Role::PROJECT_MANAGER));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(1, 2));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(1, 3));
     $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(1, 4));
     $this->assertEquals(2, $pd->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $this->assertEquals(3, count($pp->getUsers(2)));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(2, 2));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(2, 3));
     $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(2, 4));
 }
開發者ID:peripatetic-sojourner,項目名稱:kanboard,代碼行數:26,代碼來源:ProjectDuplicationTest.php

示例9: testCloneTeamProjectToPrivatProject

 public function testCloneTeamProjectToPrivatProject()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectUserRole($this->container);
     $u = new User($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'user1')));
     $this->assertEquals(3, $u->create(array('username' => 'user2')));
     $this->assertEquals(1, $p->create(array('name' => 'P1'), 2));
     $project = $p->getById(1);
     $this->assertEquals(2, $project['owner_id']);
     $this->assertEquals(0, $project['is_private']);
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MANAGER));
     $this->assertTrue($pp->addUser(1, 1, Role::PROJECT_MEMBER));
     $this->assertEquals(2, $pd->duplicate(1, array('projectPermission'), 3, 'My private project', true));
     $this->assertCount(1, $pp->getUsers(2));
     $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(2, 3));
     $project = $p->getById(2);
     $this->assertEquals(3, $project['owner_id']);
     $this->assertEquals(1, $project['is_private']);
 }
開發者ID:perburn,項目名稱:kanboard,代碼行數:22,代碼來源:ProjectDuplicationTest.php


注:本文中的Kanboard\Model\Project::getById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。