public function testAclType() { $values = array('grant', 'deny'); foreach ($values as $value) { $this->assertTrue(\Zimbra\Enum\AclType::has($value)); } }
public function testZimletAcl() { $cos = $this->faker->word; $acl = new ZimletAcl($cos, AclType::DENY()); $this->assertSame($cos, $acl->getCos()); $this->assertSame('deny', $acl->getAcl()->value()); $acl->setCos($cos)->setAcl(AclType::GRANT()); $this->assertSame($cos, $acl->getCos()); $this->assertSame('grant', $acl->getAcl()->value()); $xml = '<?xml version="1.0"?>' . "\n" . '<acl cos="' . $cos . '" acl="' . AclType::GRANT() . '" />'; $this->assertXmlStringEqualsXmlString($xml, (string) $acl); $array = ['acl' => ['cos' => $cos, 'acl' => AclType::GRANT()->value()]]; $this->assertEquals($array, $acl->toArray()); }
public function testModifyZimletApi() { $cos = $this->faker->word; $name = $this->faker->word; $value = mt_rand(0, 10); $acl = new ZimletAcl($cos, AclType::DENY()); $status = new ValueAttrib(ZimletStatus::DISABLED()->value()); $priority = new IntegerValueAttrib($value); $zimlet = new ZimletAclStatusPri($name, $acl, $status, $priority); $this->api->modifyZimlet($zimlet); $client = $this->api->getClient(); $req = $client->lastRequest(); $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:ModifyZimletRequest>' . '<urn1:zimlet name="' . $name . '">' . '<urn1:acl cos="' . $cos . '" acl="' . AclType::DENY() . '" />' . '<urn1:status value="' . ZimletStatus::DISABLED() . '" />' . '<urn1:priority value="' . $value . '" />' . '</urn1:zimlet>' . '</urn1:ModifyZimletRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testZimletAclStatusPri() { $name = $this->faker->word; $cos = $this->faker->word; $priority_value = mt_rand(0, 10); $acl = new ZimletAcl($cos, AclType::DENY()); $status = new ValueAttrib(ZimletStatus::ENABLED()->value()); $priority = new IntegerValueAttrib($priority_value); $zimlet = new ZimletAclStatusPri($name, $acl, $status, $priority); $this->assertSame($name, $zimlet->getName()); $this->assertSame($acl, $zimlet->getAcl()); $this->assertSame($status, $zimlet->getStatus()); $this->assertSame($priority, $zimlet->getPriority()); $zimlet->setName($name)->setAcl($acl)->setStatus($status)->setPriority($priority); $this->assertSame($name, $zimlet->getName()); $this->assertSame($acl, $zimlet->getAcl()); $this->assertSame($status, $zimlet->getStatus()); $this->assertSame($priority, $zimlet->getPriority()); $xml = '<?xml version="1.0"?>' . "\n" . '<zimlet name="' . $name . '">' . '<acl cos="' . $cos . '" acl="' . AclType::DENY() . '" />' . '<status value="' . ZimletStatus::ENABLED() . '" />' . '<priority value="' . $priority_value . '" />' . '</zimlet>'; $this->assertXmlStringEqualsXmlString($xml, (string) $zimlet); $array = ['zimlet' => ['name' => $name, 'acl' => ['cos' => $cos, 'acl' => AclType::DENY()->value()], 'status' => ['value' => ZimletStatus::ENABLED()->value()], 'priority' => ['value' => $priority_value]]]; $this->assertEquals($array, $zimlet->toArray()); }
public function testModifyZimlet() { $cos = self::randomName(); $name = self::randomName(); $value = mt_rand(0, 10); $acl = new \Zimbra\Admin\Struct\ZimletAcl($cos, AclType::DENY()); $status = new \Zimbra\Admin\Struct\ValueAttrib(ZimletStatus::DISABLED()->value()); $priority = new \Zimbra\Admin\Struct\IntegerValueAttrib($value); $zimlet = new \Zimbra\Admin\Struct\ZimletAclStatusPri($name, $acl, $status, $priority); $req = new \Zimbra\Admin\Request\ModifyZimlet($zimlet); $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req); $this->assertSame($zimlet, $req->getZimlet()); $req->setZimlet($zimlet); $this->assertSame($zimlet, $req->getZimlet()); $xml = '<?xml version="1.0"?>' . "\n" . '<ModifyZimletRequest>' . '<zimlet name="' . $name . '">' . '<acl cos="' . $cos . '" acl="' . AclType::DENY() . '" />' . '<status value="' . ZimletStatus::DISABLED() . '" />' . '<priority value="' . $value . '" />' . '</zimlet>' . '</ModifyZimletRequest>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['ModifyZimletRequest' => ['_jsns' => 'urn:zimbraAdmin', 'zimlet' => ['name' => $name, 'acl' => ['cos' => $cos, 'acl' => AclType::DENY()->value()], 'status' => ['value' => ZimletStatus::DISABLED()->value()], 'priority' => ['value' => $value]]]]; $this->assertEquals($array, $req->toArray()); }