本文整理匯總了PHP中Model\Project::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Project::update方法的具體用法?PHP Project::update怎麽用?PHP Project::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\Project
的用法示例。
在下文中一共展示了Project::update方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAllowEverybody
public function testAllowEverybody()
{
$user = new User($this->container);
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
$this->assertNotFalse($user->create(array('username' => 'unittest#2', 'password' => 'unittest')));
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertFalse($pp->isEverybodyAllowed(1));
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertFalse($pp->isUserAllowed(1, 2));
$this->assertFalse($pp->isUserAllowed(1, 3));
$this->assertEquals(array(), $pp->getMembers(1));
$this->assertEquals(array('Unassigned'), $pp->getMemberList(1));
$this->assertEmpty($pp->getMemberProjects(1));
$this->assertEmpty($pp->getMemberProjects(2));
$this->assertEmpty($pp->getMemberProjects(3));
$this->assertEmpty($pp->getMemberProjectIds(1));
$this->assertEmpty($pp->getMemberProjectIds(2));
$this->assertEmpty($pp->getMemberProjectIds(3));
$this->assertEmpty($pp->getActiveMemberProjectIds(1));
$this->assertEmpty($pp->getActiveMemberProjectIds(2));
$this->assertEmpty($pp->getActiveMemberProjectIds(3));
$this->assertEmpty($pp->getActiveMemberProjects(1));
$this->assertEmpty($pp->getActiveMemberProjects(2));
$this->assertEmpty($pp->getActiveMemberProjects(3));
$this->assertTrue($p->update(array('id' => 1, 'is_everybody_allowed' => 1)));
$this->assertTrue($pp->isEverybodyAllowed(1));
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertTrue($pp->isUserAllowed(1, 2));
$this->assertTrue($pp->isUserAllowed(1, 3));
$this->assertEquals(array('1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMembers(1));
$this->assertEquals(array('Unassigned', '1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMemberList(1));
$this->assertNotEmpty($pp->getMemberProjects(1));
$this->assertNotEmpty($pp->getMemberProjects(2));
$this->assertNotEmpty($pp->getMemberProjects(3));
$this->assertNotEmpty($pp->getMemberProjectIds(1));
$this->assertNotEmpty($pp->getMemberProjectIds(2));
$this->assertNotEmpty($pp->getMemberProjectIds(3));
$this->assertNotEmpty($pp->getActiveMemberProjectIds(1));
$this->assertNotEmpty($pp->getActiveMemberProjectIds(2));
$this->assertNotEmpty($pp->getActiveMemberProjectIds(3));
$this->assertNotEmpty($pp->getActiveMemberProjects(1));
$this->assertNotEmpty($pp->getActiveMemberProjects(2));
$this->assertNotEmpty($pp->getActiveMemberProjects(3));
$this->assertTrue($p->disable(1));
$this->assertEmpty($pp->getActiveMemberProjectIds(1));
$this->assertEmpty($pp->getActiveMemberProjectIds(2));
$this->assertEmpty($pp->getActiveMemberProjectIds(3));
$this->assertEmpty($pp->getActiveMemberProjects(1));
$this->assertEmpty($pp->getActiveMemberProjects(2));
$this->assertEmpty($pp->getActiveMemberProjects(3));
}
示例2: function
});
$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);
return $valid && $project->update($values);
});
$server->register('removeProject', function ($project_id) use($project) {
return $project->remove($project_id);
});
$server->register('enableProject', function ($project_id) use($project) {
return $project->enable($project_id);
});
$server->register('disableProject', function ($project_id) use($project) {
return $project->disable($project_id);
});
$server->register('enableProjectPublicAccess', function ($project_id) use($project) {
return $project->enablePublicAccess($project_id);
});
$server->register('disableProjectPublicAccess', function ($project_id) use($project) {
return $project->disablePublicAccess($project_id);
示例3: 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]);
}