예제 #1
0
 public function testAdminCreateWaitSetApi()
 {
     $name = $this->faker->word;
     $id = $this->faker->word;
     $token = $this->faker->word;
     $a = new WaitSetAddSpec($name, $id, $token, [InterestType::MESSAGES(), InterestType::CONTACTS()]);
     $add = new WaitSetSpec([$a]);
     $this->api->adminCreateWaitSet($add, [InterestType::FOLDERS(), InterestType::MESSAGES()], true);
     $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:AdminCreateWaitSetRequest defTypes="f,m" allAccounts="true">' . '<urn1:add>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="m,c" />' . '</urn1:add>' . '</urn1:AdminCreateWaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
예제 #2
0
 public function testAdminWaitSetApi()
 {
     $name = $this->faker->word;
     $id = $this->faker->word;
     $token = $this->faker->word;
     $waitSet = $this->faker->word;
     $seq = $this->faker->word;
     $timeout = mt_rand(0, 1000);
     $a = new WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS(), InterestType::MESSAGES(), InterestType::CONTACTS()]);
     $add = new WaitSetSpec([$a]);
     $update = new WaitSetSpec([$a]);
     $a = new Id($id);
     $remove = new WaitSetId([$a]);
     $this->api->adminWaitSet($waitSet, $seq, $add, $update, $remove, true, [InterestType::FOLDERS(), InterestType::MESSAGES()], $timeout);
     $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:AdminWaitSetRequest waitSet="' . $waitSet . '" seq="' . $seq . '" block="true" defTypes="f,m" timeout="' . $timeout . '" >' . '<urn1:add>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</urn1:add>' . '<urn1:update>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</urn1:update>' . '<urn1:remove>' . '<urn1:a id="' . $id . '" />' . '</urn1:remove>' . '</urn1:AdminWaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
예제 #3
0
 public function testWaitSetAddSpec()
 {
     $name = $this->faker->word;
     $id = $this->faker->word;
     $token = $this->faker->word;
     $waitSet = new WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS()]);
     $this->assertSame($name, $waitSet->getName());
     $this->assertSame($id, $waitSet->getId());
     $this->assertSame($token, $waitSet->getToken());
     $this->assertSame('f', $waitSet->getInterests());
     $waitSet->setName($name)->setId($id)->setToken($token)->addInterest(InterestType::MESSAGES())->addInterest(InterestType::CONTACTS());
     $this->assertSame($name, $waitSet->getName());
     $this->assertSame($id, $waitSet->getId());
     $this->assertSame($token, $waitSet->getToken());
     $this->assertSame('f,m,c', $waitSet->getInterests());
     $xml = '<?xml version="1.0"?>' . "\n" . '<a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $waitSet);
     $array = ['a' => ['name' => $name, 'id' => $id, 'token' => $token, 'types' => 'f,m,c']];
     $this->assertEquals($array, $waitSet->toArray());
 }
예제 #4
0
 public function testAdminWaitSet()
 {
     $name = self::randomName();
     $id = self::randomName();
     $token = self::randomName();
     $waitSet = self::randomName();
     $seq = self::randomName();
     $timeout = mt_rand(0, 1000);
     $a = new \Zimbra\Struct\WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS(), InterestType::MESSAGES(), InterestType::CONTACTS()]);
     $add = new \Zimbra\Struct\WaitSetSpec([$a]);
     $update = new \Zimbra\Struct\WaitSetSpec([$a]);
     $a = new \Zimbra\Struct\Id($id);
     $remove = new \Zimbra\Struct\WaitSetId([$a]);
     $req = new \Zimbra\Admin\Request\AdminWaitSet($waitSet, $seq, $add, $update, $remove, false, [InterestType::FOLDERS()], $timeout);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($waitSet, $req->getWaitSetId());
     $this->assertSame($seq, $req->getLastKnownSeqNo());
     $this->assertSame($add, $req->getAddAccounts());
     $this->assertSame($update, $req->getUpdateAccounts());
     $this->assertSame($remove, $req->getRemoveAccounts());
     $this->assertFalse($req->getBlock());
     $this->assertSame('f', $req->getDefaultInterests());
     $this->assertSame($timeout, $req->getTimeout());
     $req->setWaitSetId($waitSet)->setLastKnownSeqNo($seq)->setBlock(true)->setAddAccounts($add)->setUpdateAccounts($update)->setRemoveAccounts($remove)->addDefaultInterest(InterestType::MESSAGES())->addDefaultInterest(InterestType::CONTACTS())->setTimeout($timeout);
     $this->assertSame($waitSet, $req->getWaitSetId());
     $this->assertSame($seq, $req->getLastKnownSeqNo());
     $this->assertSame($add, $req->getAddAccounts());
     $this->assertSame($update, $req->getUpdateAccounts());
     $this->assertSame($remove, $req->getRemoveAccounts());
     $this->assertTrue($req->getBlock());
     $this->assertSame('f,m,c', $req->getDefaultInterests());
     $this->assertSame($timeout, $req->getTimeout());
     $xml = '<?xml version="1.0"?>' . "\n" . '<AdminWaitSetRequest waitSet="' . $waitSet . '" seq="' . $seq . '" block="true" defTypes="f,m,c" timeout="' . $timeout . '" >' . '<add>' . '<a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</add>' . '<update>' . '<a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</update>' . '<remove>' . '<a id="' . $id . '" />' . '</remove>' . '</AdminWaitSetRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['AdminWaitSetRequest' => ['_jsns' => 'urn:zimbraAdmin', 'waitSet' => $waitSet, 'seq' => $seq, 'block' => true, 'defTypes' => 'f,m,c', 'timeout' => $timeout, 'add' => ['a' => [['name' => $name, 'id' => $id, 'token' => $token, 'types' => 'f,m,c']]], 'update' => ['a' => [['name' => $name, 'id' => $id, 'token' => $token, 'types' => 'f,m,c']]], 'remove' => ['a' => [['id' => $id]]]]];
     $this->assertEquals($array, $req->toArray());
 }