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 testSubscribeDistributionListApi()
 {
     $value = $this->faker->word;
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $this->api->subscribeDistributionList(DLSubscribeOp::SUBSCRIBE(), $dl);
     $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:SubscribeDistributionListRequest op="' . DLSubscribeOp::SUBSCRIBE() . '">' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '</urn1:SubscribeDistributionListRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testDistributionListSubscribeReq()
 {
     $value = $this->faker->word;
     $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::UNSUBSCRIBE(), $value, false);
     $this->assertTrue($subsReq->getOp()->is('unsubscribe'));
     $this->assertSame($value, $subsReq->getValue());
     $this->assertFalse($subsReq->getBccOwners());
     $subsReq->setOp(DLSubscribeOp::SUBSCRIBE())->setBccOwners(true);
     $this->assertTrue($subsReq->getOp()->is('subscribe'));
     $this->assertTrue($subsReq->getBccOwners());
     $xml = '<?xml version="1.0"?>' . "\n" . '<subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</subsReq>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $subsReq);
     $array = ['subsReq' => ['op' => DLSubscribeOp::SUBSCRIBE()->value(), '_content' => $value, 'bccOwners' => true]];
     $this->assertEquals($array, $subsReq->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);
 }
Exemple #5
0
 public function testDistributionListSubscribeOp()
 {
     $values = array('subscribe', 'unsubscribe');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\DistributionListSubscribeOp::has($value));
     }
 }
 public function testSubscribeDistributionList()
 {
     $value = md5(self::randomString());
     $dl = new \Zimbra\Account\Struct\DistributionListSelector(DLBy::NAME(), $value);
     $req = new \Zimbra\Account\Request\SubscribeDistributionList(DLSubscribeOp::UNSUBSCRIBE(), $dl);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame('unsubscribe', $req->getOp()->value());
     $this->assertSame($dl, $req->getDl());
     $req->setOp(DLSubscribeOp::SUBSCRIBE())->setDl($dl);
     $this->assertSame('subscribe', $req->getOp()->value());
     $this->assertSame($dl, $req->getDl());
     $xml = '<?xml version="1.0"?>' . "\n" . '<SubscribeDistributionListRequest op="' . DLSubscribeOp::SUBSCRIBE() . '">' . '<dl by="' . DLBy::NAME() . '">' . $value . '</dl>' . '</SubscribeDistributionListRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['SubscribeDistributionListRequest' => ['_jsns' => 'urn:zimbraAccount', 'op' => DLSubscribeOp::SUBSCRIBE()->value(), 'dl' => ['by' => DLBy::NAME()->value(), '_content' => $value]]];
     $this->assertEquals($array, $req->toArray());
 }