本文整理汇总了PHP中Model\Project::duplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::duplicate方法的具体用法?PHP Project::duplicate怎么用?PHP Project::duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\Project
的用法示例。
在下文中一共展示了Project::duplicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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']);
}