public function testDistributionListAction() { $name = $this->faker->word; $value = $this->faker->word; $member = $this->faker->word; $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::SUBSCRIBE(), $value, true); $owner = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value); $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value); $right = new DistributionListRightSpec($name, [$grantee]); $attr = new KeyValuePair($name, $value); $dl = new DistributionListAction(Operation::MODIFY(), $name, $subsReq, [$member], [$owner], [$right]); $this->assertTrue($dl->getOp()->is('modify')); $this->assertSame($name, $dl->getNewName()); $this->assertSame($subsReq, $dl->getSubsReq()); $this->assertSame([$member], $dl->getMembers()->all()); $this->assertSame([$owner], $dl->getOwners()->all()); $this->assertSame([$right], $dl->getRights()->all()); $dl = new DistributionListAction(Operation::MODIFY()); $dl->setOp(Operation::DELETE())->setNewName($name)->setSubsReq($subsReq)->addMember($member)->addOwner($owner)->addRight($right)->addAttr($attr); $this->assertTrue($dl->getOp()->is('delete')); $this->assertSame($name, $dl->getNewName()); $this->assertSame($subsReq, $dl->getSubsReq()); $this->assertSame([$member], $dl->getMembers()->all()); $this->assertSame([$owner], $dl->getOwners()->all()); $this->assertSame([$right], $dl->getRights()->all()); $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . Operation::DELETE() . '">' . '<newName>' . $name . '</newName>' . '<subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</subsReq>' . '<a n="' . $name . '">' . $value . '</a>' . '<dlm>' . $member . '</dlm>' . '<owner type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value . '</owner>' . '<right right="' . $name . '">' . '<grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</grantee>' . '</right>' . '</action>'; $this->assertXmlStringEqualsXmlString($xml, (string) $dl); $array = ['action' => ['op' => Operation::DELETE()->value(), 'newName' => $name, 'subsReq' => ['op' => DLSubscribeOp::SUBSCRIBE()->value(), '_content' => $value, 'bccOwners' => true], 'dlm' => [$member], 'owner' => [['type' => GranteeType::USR()->value(), '_content' => $value, 'by' => DLGranteeBy::ID()->value()]], 'right' => [['right' => $name, 'grantee' => [['type' => GranteeType::ALL()->value(), '_content' => $value, 'by' => DLGranteeBy::NAME()->value()]]]], 'a' => [['n' => $name, '_content' => $value]]]]; $this->assertEquals($array, $dl->toArray()); }
public function testDistributionListGranteeSelector() { $value = $this->faker->word; $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::ID(), $value); $this->assertTrue($grantee->getType()->is('all')); $this->assertTrue($grantee->getBy()->is('id')); $this->assertSame($value, $grantee->getValue()); $grantee->setType(GranteeType::USR())->setBy(DLGranteeBy::NAME()); $this->assertTrue($grantee->getType()->is('usr')); $this->assertTrue($grantee->getBy()->is('name')); $xml = '<?xml version="1.0"?>' . "\n" . '<grantee type="' . GranteeType::USR() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</grantee>'; $this->assertXmlStringEqualsXmlString($xml, (string) $grantee); $array = ['grantee' => ['type' => GranteeType::USR()->value(), '_content' => $value, 'by' => DLGranteeBy::NAME()->value()]]; $this->assertEquals($array, $grantee->toArray()); }
public function testDistributionListActionApi() { $name = $this->faker->word; $value = $this->faker->word; $member = $this->faker->word; $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::SUBSCRIBE(), $value, true); $owner = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value); $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value); $right = new DistributionListRightSpec($name, [$grantee]); $a = new KeyValuePair($name, $value); $action = new DLAction(Operation::MODIFY(), $name, $subsReq, [$member], [$owner], [$right], [$a]); $dl = new DistributionListSelector(DLBy::NAME(), $value); $attr = new Attr($name, $value, true); $this->api->distributionListAction($dl, $action, [$attr]); $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:DistributionListActionRequest>' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '<urn1:action op="' . Operation::MODIFY() . '">' . '<urn1:newName>' . $name . '</urn1:newName>' . '<urn1:subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</urn1:subsReq>' . '<urn1:a n="' . $name . '">' . $value . '</urn1:a>' . '<urn1:dlm>' . $member . '</urn1:dlm>' . '<urn1:owner type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value . '</urn1:owner>' . '<urn1:right right="' . $name . '">' . '<urn1:grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</urn1:grantee>' . '</urn1:right>' . '</urn1:action>' . '<urn1:a name="' . $name . '" pd="true">' . $value . '</urn1:a>' . '</urn1:DistributionListActionRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testDistributionListRightSpec() { $name = $this->faker->word; $value1 = $this->faker->word; $value2 = $this->faker->word; $value3 = $this->faker->word; $grantee1 = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value1); $grantee2 = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value2); $grantee3 = new DistributionListGranteeSelector(GranteeType::GRP(), DLGranteeBy::NAME(), $value3); $right = new DistributionListRightSpec($name, [$grantee1, $grantee2]); $this->assertSame($name, $right->getRight()); $this->assertSame([$grantee1, $grantee2], $right->getGrantees()->all()); $right->setRight($name)->addGrantee($grantee3); $this->assertSame($name, $right->getRight()); $this->assertSame([$grantee1, $grantee2, $grantee3], $right->getGrantees()->all()); $xml = '<?xml version="1.0"?>' . "\n" . '<right right="' . $name . '">' . '<grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value1 . '</grantee>' . '<grantee type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value2 . '</grantee>' . '<grantee type="' . GranteeType::GRP() . '" by="' . DLGranteeBy::NAME() . '">' . $value3 . '</grantee>' . '</right>'; $this->assertXmlStringEqualsXmlString($xml, (string) $right); $array = ['right' => ['right' => $name, 'grantee' => [['type' => GranteeType::ALL()->value(), '_content' => $value1, 'by' => DLGranteeBy::NAME()->value()], ['type' => GranteeType::USR()->value(), '_content' => $value2, 'by' => DLGranteeBy::ID()->value()], ['type' => GranteeType::GRP()->value(), '_content' => $value3, 'by' => DLGranteeBy::NAME()->value()]]]]; $this->assertEquals($array, $right->toArray()); }
public function testDistributionListGranteeBy() { $values = array('id', 'name'); foreach ($values as $value) { $this->assertTrue(\Zimbra\Enum\DistributionListGranteeBy::has($value)); } }
public function testDistributionListAction() { $name = self::randomName(); $value = md5(self::randomString()); $member = self::randomName(); $subsReq = new \Zimbra\Account\Struct\DistributionListSubscribeReq(DLSubscribeOp::SUBSCRIBE(), $value, true); $owner = new \Zimbra\Account\Struct\DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value); $grantee = new \Zimbra\Account\Struct\DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value); $right = new \Zimbra\Account\Struct\DistributionListRightSpec($name, [$grantee]); $a = new \Zimbra\Struct\KeyValuePair($name, $value); $action = new \Zimbra\Account\Struct\DistributionListAction(Operation::MODIFY(), $name, $subsReq, [$member], [$owner], [$right], [$a]); $dl = new \Zimbra\Account\Struct\DistributionListSelector(DLBy::NAME(), $value); $attr = new \Zimbra\Account\Struct\Attr($name, $value, true); $req = new \Zimbra\Account\Request\DistributionListAction($dl, $action, [$attr]); $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req); $this->assertSame($dl, $req->getDl()); $this->assertSame($action, $req->getAction()); $this->assertSame([$attr], $req->getAttrs()->all()); $req->setDl($dl)->setAction($action)->addAttr($attr); $this->assertSame($dl, $req->getDl()); $this->assertSame($action, $req->getAction()); $this->assertSame([$attr, $attr], $req->getAttrs()->all()); $req->getAttrs()->remove(1); $xml = '<?xml version="1.0"?>' . "\n" . '<DistributionListActionRequest>' . '<dl by="' . DLBy::NAME() . '">' . $value . '</dl>' . '<action op="' . Operation::MODIFY() . '">' . '<newName>' . $name . '</newName>' . '<subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</subsReq>' . '<a n="' . $name . '">' . $value . '</a>' . '<dlm>' . $member . '</dlm>' . '<owner type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value . '</owner>' . '<right right="' . $name . '">' . '<grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</grantee>' . '</right>' . '</action>' . '<a name="' . $name . '" pd="true">' . $value . '</a>' . '</DistributionListActionRequest>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['DistributionListActionRequest' => ['_jsns' => 'urn:zimbraAccount', 'dl' => ['by' => DLBy::NAME()->value(), '_content' => $value], 'action' => ['op' => Operation::MODIFY()->value(), 'newName' => $name, 'subsReq' => ['op' => DLSubscribeOp::SUBSCRIBE()->value(), '_content' => $value, 'bccOwners' => true], 'dlm' => [$member], 'owner' => [['type' => GranteeType::USR()->value(), '_content' => $value, 'by' => DLGranteeBy::ID()->value()]], 'right' => [['right' => $name, 'grantee' => [['type' => GranteeType::ALL()->value(), '_content' => $value, 'by' => DLGranteeBy::NAME()->value()]]]], 'a' => [['n' => $name, '_content' => $value]]], 'a' => [['name' => $name, 'pd' => true, '_content' => $value]]]]; $this->assertEquals($array, $req->toArray()); }