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 testGetAdminConsoleUICompApi()
 {
     $value = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $this->api->getAdminConsoleUIComp($account, $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:zimbraAdmin">' . '<env:Body>' . '<urn1:GetAdminConsoleUICompRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '</urn1:GetAdminConsoleUICompRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testGetDistributionListMembershipApi()
 {
     $value = $this->faker->word;
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $this->api->getDistributionListMembership($dl, $limit, $offset);
     $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:GetDistributionListMembershipRequest limit="' . $limit . '" offset="' . $offset . '">' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '</urn1:GetDistributionListMembershipRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testGetDistributionListApi()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $attr = new Attr($name, $value, true);
     $this->api->getDistributionList($dl, true, 'sendToDistList', [$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:GetDistributionListRequest needOwners="true" needRights="sendToDistList">' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '<urn1:a name="' . $name . '" pd="true">' . $value . '</urn1:a>' . '</urn1:GetDistributionListRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testDistributionListSelector()
 {
     $value = $this->faker->word;
     $dl = new DistributionListSelector(DLBy::ID(), $value);
     $this->assertTrue($dl->getBy()->is('id'));
     $this->assertSame($value, $dl->getValue());
     $dl->setBy(DLBy::NAME());
     $this->assertTrue($dl->getBy()->is('name'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<dl by="' . DLBy::NAME() . '">' . $value . '</dl>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $dl);
     $array = ['dl' => ['by' => DLBy::NAME()->value(), '_content' => $value]];
     $this->assertEquals($array, $dl->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);
 }
Esempio n. 7
0
 public function testDistributionListBy()
 {
     $values = array('id', 'name');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\DistributionListBy::has($value));
     }
 }
Esempio n. 8
0
 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());
 }
Esempio n. 9
0
 public function testGetDistributionListMembership()
 {
     $value = self::randomName();
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $dl = new \Zimbra\Admin\Struct\DistributionListSelector(DLBy::NAME(), $value);
     $req = new \Zimbra\Admin\Request\GetDistributionListMembership($dl, $limit, $offset);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($dl, $req->getDl());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $req->setDl($dl)->setLimit($limit)->setOffset($offset);
     $this->assertSame($dl, $req->getDl());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $xml = '<?xml version="1.0"?>' . "\n" . '<GetDistributionListMembershipRequest limit="' . $limit . '" offset="' . $offset . '">' . '<dl by="' . DLBy::NAME() . '">' . $value . '</dl>' . '</GetDistributionListMembershipRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['GetDistributionListMembershipRequest' => ['_jsns' => 'urn:zimbraAdmin', 'limit' => $limit, 'offset' => $offset, 'dl' => ['by' => DLBy::NAME()->value(), '_content' => $value]]];
     $this->assertEquals($array, $req->toArray());
 }