本文整理汇总了PHP中Model\Project::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getById方法的具体用法?PHP Project::getById怎么用?PHP Project::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\Project
的用法示例。
在下文中一共展示了Project::getById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCloneProjectWithUsers
public function testCloneProjectWithUsers()
{
$p = new Project($this->container);
$c = new Category($this->container);
$pp = new ProjectPermission($this->container);
$u = new User($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, $p->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));
}
示例2: testDisablePublicAccess
public function testDisablePublicAccess()
{
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->enablePublicAccess(1));
$this->assertTrue($p->disablePublicAccess(1));
$project = $p->getById(1);
$this->assertNotEmpty($project);
$this->assertEquals(0, $project['is_public']);
$this->assertEmpty($project['token']);
$this->assertFalse($p->disablePublicAccess(123));
}
示例3: testCloneProjectWithCategories
public function testCloneProjectWithCategories()
{
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'P1')));
$this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
$this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1)));
$this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1)));
$this->assertEquals(2, $p->duplicate(1));
$project = $p->getById(2);
$this->assertNotEmpty($project);
$this->assertEquals('P1 (Clone)', $project['name']);
$categories = $c->getAll(2);
$this->assertNotempty($categories);
$this->assertEquals(3, count($categories));
$this->assertEquals(4, $categories[0]['id']);
$this->assertEquals('C1', $categories[0]['name']);
$this->assertEquals(5, $categories[1]['id']);
$this->assertEquals('C2', $categories[1]['name']);
$this->assertEquals(6, $categories[2]['id']);
$this->assertEquals('C3', $categories[2]['name']);
}
示例4: 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));
}
示例5: Server
$language = $config->get('language', 'en_US');
if ($language !== 'en_US') {
Translator::load($language);
}
$server = new Server();
$server->authentication(array('jsonrpc' => $config->get('api_token')));
/**
* Project procedures
*/
$server->register('createProject', function ($name) use($project) {
$values = array('name' => $name);
list($valid, ) = $project->validateCreation($values);
return $valid && $project->create($values);
});
$server->register('getProjectById', function ($project_id) use($project) {
return $project->getById($project_id);
});
$server->register('getProjectByName', function ($name) use($project) {
return $project->getByName($name);
});
$server->register('getAllProjects', function () use($project) {
return $project->getAll();
});
$server->register('updateProject', function ($id, $name, $is_active = null, $is_public = null, $token = null) use($project) {
$values = array('id' => $id, 'name' => $name, 'is_active' => $is_active, 'is_public' => $is_public, 'token' => $token);
foreach ($values as $key => $value) {
if (is_null($value)) {
unset($values[$key]);
}
}
list($valid, ) = $project->validateModification($values);
示例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);
// 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]);
}