本文整理汇总了PHP中Printer::canEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::canEdit方法的具体用法?PHP Printer::canEdit怎么用?PHP Printer::canEdit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::canEdit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrinter
/**
* Check right on Recursive object
*/
public function testPrinter()
{
global $DB;
$DB->connect();
$ent0 = $this->sharedFixture['entity'][0];
$ent1 = $this->sharedFixture['entity'][1];
$ent2 = $this->sharedFixture['entity'][2];
$printer = new Printer();
$id[0] = $printer->add(array('name' => "Printer 1", 'entities_id' => $ent0, 'is_recursive' => 0));
$this->assertGreaterThan(0, $id[0], "Fail to create Printer 1");
$id[1] = $printer->add(array('name' => "Printer 2", 'entities_id' => $ent0, 'is_recursive' => 1));
$this->assertGreaterThan(0, $id[1], "Fail to create Printer 2");
$id[2] = $printer->add(array('name' => "Printer 3", 'entities_id' => $ent1, 'is_recursive' => 1));
$this->assertGreaterThan(0, $id[2], "Fail to create Ptiner 3");
$id[3] = $printer->add(array('name' => "Printer 4", 'entities_id' => $ent2));
$this->assertGreaterThan(0, $id[3], "Fail to create Printer 4");
// Super admin
Session::changeProfile(4);
$this->assertEquals(4, $_SESSION['glpiactiveprofile']['id']);
$this->assertEquals(31, $_SESSION['glpiactiveprofile']['printer']);
// See all
$this->assertTrue(Session::changeActiveEntities("all"));
$this->assertTrue($printer->can($id[0], READ), "Fail can read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertTrue($printer->can($id[2], READ), "Fail can read Printer 3");
$this->assertTrue($printer->can($id[3], READ), "Fail can read Printer 4");
$this->assertTrue($printer->canEdit($id[0]), "Fail can write Printer 1");
$this->assertTrue($printer->canEdit($id[1]), "Fail can write Printer 2");
$this->assertTrue($printer->canEdit($id[2]), "Fail can write Printer 3");
$this->assertTrue($printer->canEdit($id[3]), "Fail can write Printer 4");
// See only in main entity
$this->assertTrue(Session::changeActiveEntities($ent0));
$this->assertTrue($printer->can($id[0], READ), "Fail can read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertFalse($printer->can($id[2], READ), "Fail can't read Printer 3");
$this->assertFalse($printer->can($id[3], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->canEdit($id[0]), "Fail can write Printer 1");
$this->assertTrue($printer->canEdit($id[1]), "Fail can write Printer 2");
$this->assertFalse($printer->canEdit($id[2]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[3]), "Fail can't write Printer 1");
// See only in child entity 1 + parent if recursive
$this->assertTrue(Session::changeActiveEntities($ent1));
$this->assertFalse($printer->can($id[0], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertTrue($printer->can($id[2], READ), "Fail can read Printer 3");
$this->assertFalse($printer->can($id[3], READ), "Fail can't read Printer 4");
$this->assertFalse($printer->canEdit($id[0]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[1]), "Fail can't write Printer 2");
$this->assertTrue($printer->canEdit($id[2]), "Fail can write Printer 2");
$this->assertFalse($printer->canEdit($id[3]), "Fail can't write Printer 2");
// See only in child entity 2 + parent if recursive
$this->assertTrue(Session::changeActiveEntities($ent2));
$this->assertFalse($printer->can($id[0], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertFalse($printer->can($id[2], READ), "Fail can't read Printer 3");
$this->assertTrue($printer->can($id[3], READ), "Fail can read Printer 4");
$this->assertFalse($printer->canEdit($id[0]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[1]), "Fail can't write Printer 2");
$this->assertFalse($printer->canEdit($id[2]), "Fail can't write Printer 3");
$this->assertTrue($printer->canEdit($id[3]), "Fail can write Printer 4");
}