public function testZimletPrefsSpec() { $name = $this->faker->word; $zimlet = new ZimletPrefsSpec($name, ZimletStatus::ENABLED()); $this->assertSame($name, $zimlet->getName()); $this->assertSame('enabled', $zimlet->getPresence()->value()); $zimlet->setName($name)->setPresence(ZimletStatus::DISABLED()); $this->assertSame($name, $zimlet->getName()); $this->assertSame('disabled', $zimlet->getPresence()->value()); $xml = '<?xml version="1.0"?>' . "\n" . '<zimlet name="' . $name . '" presence="' . ZimletStatus::DISABLED() . '" />'; $this->assertXmlStringEqualsXmlString($xml, (string) $zimlet); $array = ['zimlet' => ['name' => $name, 'presence' => ZimletStatus::DISABLED()->value()]]; $this->assertEquals($array, $zimlet->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 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()); }