public function testCreateWaitSetApi()
 {
     $name = $this->faker->word;
     $id = $this->faker->uuid;
     $token = $this->faker->word;
     $a = new WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS()]);
     $add = new WaitSetSpec([$a]);
     $this->api->createWaitSet($add, [InterestType::FOLDERS()], 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:zimbraMail">' . '<env:Body>' . '<urn1:CreateWaitSetRequest defTypes="' . InterestType::FOLDERS() . '" allAccounts="true">' . '<urn1:add>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="' . InterestType::FOLDERS() . '" />' . '</urn1:add>' . '</urn1:CreateWaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testWaitSetSpec()
 {
     $name = $this->faker->word;
     $id = $this->faker->uuid;
     $token = $this->faker->word;
     $a = new WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS(), InterestType::MESSAGES()]);
     $add = new WaitSetSpec([$a]);
     $this->assertSame([$a], $add->getAccounts()->all());
     $add->addAccount($a);
     $this->assertSame([$a, $a], $add->getAccounts()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<add>' . '<a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m" />' . '<a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f,m" />' . '</add>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $add);
     $array = ['add' => ['a' => [['name' => $name, 'id' => $id, 'token' => $token, 'types' => 'f,m'], ['name' => $name, 'id' => $id, 'token' => $token, 'types' => 'f,m']]]];
     $this->assertEquals($array, $add->toArray());
 }
Exemple #3
0
 public function testWaitSetApi()
 {
     $id = $this->faker->uuid;
     $name = $this->faker->word;
     $token = $this->faker->word;
     $waitSet = $this->faker->uuid;
     $seq = $this->faker->word;
     $timeout = mt_rand(1, 10);
     $waitSetSpec = new WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS()]);
     $add = new WaitSetSpec([$waitSetSpec]);
     $update = new WaitSetSpec([$waitSetSpec]);
     $remove = new WaitSetId([new Id($id)]);
     $this->api->waitSet($waitSet, $seq, $add, $update, $remove, true, [InterestType::FOLDERS()], $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:zimbraMail">' . '<env:Body>' . '<urn1:WaitSetRequest waitSet="' . $waitSet . '" seq="' . $seq . '" block="true" defTypes="f" timeout="' . $timeout . '" >' . '<urn1:add>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f" />' . '</urn1:add>' . '<urn1:update>' . '<urn1:a name="' . $name . '" id="' . $id . '" token="' . $token . '" types="f" />' . '</urn1:update>' . '<urn1:remove>' . '<urn1:a id="' . $id . '" />' . '</urn1:remove>' . '</urn1:WaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 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());
 }
Exemple #5
0
 public function testInterestType()
 {
     $values = array('f', 'm', 'c', 'a', 't', 'd', 'all');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\InterestType::has($value));
     }
 }
Exemple #6
0
 public function testWaitSet()
 {
     $id = new \Zimbra\Struct\Id('id');
     $waitSet = new \Zimbra\Struct\WaitSetAddSpec('name', 'id', 'token', array(InterestType::FOLDERS()));
     $add = new \Zimbra\Struct\WaitSetSpec(array($waitSet));
     $update = new \Zimbra\Struct\WaitSetSpec(array($waitSet));
     $remove = new \Zimbra\Struct\WaitSetId(array($id));
     $this->_api->waitSet('waitSet', 'seq', $add, $update, $remove, true, array(InterestType::FOLDERS()), 10);
     $client = $this->_api->client();
     $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:zimbraMail">' . '<env:Body>' . '<urn1:WaitSetRequest waitSet="waitSet" seq="seq" block="true" defTypes="f" timeout="10" >' . '<urn1:add>' . '<urn1:a name="name" id="id" token="token" types="f" />' . '</urn1:add>' . '<urn1:update>' . '<urn1:a name="name" id="id" token="token" types="f" />' . '</urn1:update>' . '<urn1:remove>' . '<urn1:a id="id" />' . '</urn1:remove>' . '</urn1:WaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Exemple #7
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]);
     $this->_api->adminWaitSet($waitSet, $seq, $add, $update, $remove, true, [InterestType::FOLDERS(), InterestType::MESSAGES()], $timeout);
     $client = $this->_api->client();
     $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);
 }
 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());
 }
 public function testWaitSet()
 {
     $id = new \Zimbra\Struct\Id('id');
     $waitSet = new \Zimbra\Struct\WaitSetAddSpec('name', 'id', 'token', array(InterestType::FOLDERS()));
     $add = new \Zimbra\Struct\WaitSetSpec(array($waitSet));
     $update = new \Zimbra\Struct\WaitSetSpec(array($waitSet));
     $remove = new \Zimbra\Struct\WaitSetId(array($id));
     $req = new \Zimbra\Mail\Request\WaitSet('waitSet', 'seq', $add, $update, $remove, true, array(InterestType::FOLDERS()), 10);
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame('waitSet', $req->waitSet());
     $this->assertSame('seq', $req->seq());
     $this->assertSame($add, $req->add());
     $this->assertSame($update, $req->update());
     $this->assertSame($remove, $req->remove());
     $this->assertTrue($req->block());
     $this->assertSame('f', $req->defTypes());
     $this->assertSame(10, $req->timeout());
     $req->waitSet('waitSet')->seq('seq')->add($add)->update($update)->remove($remove)->block(true)->addDefTypes(InterestType::MESSAGES())->timeout(10);
     $this->assertSame('waitSet', $req->waitSet());
     $this->assertSame('seq', $req->seq());
     $this->assertSame($add, $req->add());
     $this->assertSame($update, $req->update());
     $this->assertSame($remove, $req->remove());
     $this->assertTrue($req->block());
     $this->assertSame('f,m', $req->defTypes());
     $this->assertSame(10, $req->timeout());
     $xml = '<?xml version="1.0"?>' . "\n" . '<WaitSetRequest waitSet="waitSet" seq="seq" block="true" defTypes="f,m" timeout="10">' . '<add>' . '<a name="name" id="id" token="token" types="f" />' . '</add>' . '<update>' . '<a name="name" id="id" token="token" types="f" />' . '</update>' . '<remove>' . '<a id="id" />' . '</remove>' . '</WaitSetRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('WaitSetRequest' => array('_jsns' => 'urn:zimbraMail', 'waitSet' => 'waitSet', 'seq' => 'seq', 'block' => true, 'defTypes' => 'f,m', 'timeout' => 10, 'add' => array('a' => array(array('name' => 'name', 'id' => 'id', 'token' => 'token', 'types' => 'f'))), 'update' => array('a' => array(array('name' => 'name', 'id' => 'id', 'token' => 'token', 'types' => 'f'))), 'remove' => array('a' => array(array('id' => 'id')))));
     $this->assertEquals($array, $req->toArray());
 }