public function testModifyZimletPrefsApi() { $name = $this->faker->word; $zimlet = new ZimletPrefsSpec($name, ZimletStatus::ENABLED()); $this->api->modifyZimletPrefs([$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:zimbraAccount">' . '<env:Body>' . '<urn1:ModifyZimletPrefsRequest>' . '<urn1:zimlet name="' . $name . '" presence="' . ZimletStatus::ENABLED() . '" />' . '</urn1:ModifyZimletPrefsRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
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 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 testModifyZimletPrefs() { $name = self::randomName(); $zimlet = new \Zimbra\Account\Struct\ZimletPrefsSpec($name, ZimletStatus::ENABLED()); $req = new \Zimbra\Account\Request\ModifyZimletPrefs([$zimlet]); $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req); $this->assertSame([$zimlet], $req->getZimlets()->all()); $req->addZimlet($zimlet); $this->assertSame([$zimlet, $zimlet], $req->getZimlets()->all()); $req->getZimlets()->remove(1); $xml = '<?xml version="1.0"?>' . "\n" . '<ModifyZimletPrefsRequest>' . '<zimlet name="' . $name . '" presence="' . ZimletStatus::ENABLED() . '" />' . '</ModifyZimletPrefsRequest>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['ModifyZimletPrefsRequest' => ['_jsns' => 'urn:zimbraAccount', 'zimlet' => [['name' => $name, 'presence' => ZimletStatus::ENABLED()->value()]]]]; $this->assertEquals($array, $req->toArray()); }