Exemple #1
0
 public function testSearchApi()
 {
     $id = $this->faker->uuid;
     $stdoff = mt_rand(1, 10);
     $dayoff = mt_rand(1, 10);
     $name = $this->faker->word;
     $sortVal = $this->faker->word;
     $endSortVal = $this->faker->word;
     $header = new AttributeName($name);
     $tz = new CalTZInfo($id, $stdoff, $dayoff);
     $cursor = new CursorInfo($id, $sortVal, $endSortVal, true);
     $query = $this->faker->word;
     $locale = $this->faker->word;
     $status = $this->faker->word;
     $start = mt_rand(1, 10);
     $end = mt_rand(1, 10);
     $types = $this->faker->word;
     $groupBy = $this->faker->word;
     $fetch = $this->faker->word;
     $max = mt_rand(1, 10);
     $resultMode = $this->faker->word;
     $field = $this->faker->word;
     $limit = mt_rand(1, 10);
     $offset = mt_rand(1, 10);
     $this->api->search(true, $query, [$header], $tz, $locale, $cursor, true, true, $status, $start, $end, true, $types, $groupBy, true, SortBy::NONE(), $fetch, true, $max, true, true, true, true, true, $resultMode, true, $field, $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:zimbraMail">' . '<env:Body>' . '<urn1:SearchRequest warmup="true" includeTagDeleted="true" includeTagMuted="true" allowableTaskStatus="' . $status . '" calExpandInstStart="' . $start . '" calExpandInstEnd="' . $end . '" inDumpster="true" types="' . $types . '" groupBy="' . $groupBy . '" quick="true" sortBy="' . SortBy::NONE() . '" fetch="' . $fetch . '" read="true" max="' . $max . '" html="true" needExp="true" neuter="true" recip="true" prefetch="true" resultMode="' . $resultMode . '" fullConversation="true" field="' . $field . '" limit="' . $limit . '" offset="' . $offset . '">' . '<urn1:query>' . $query . '</urn1:query>' . '<urn1:tz id="' . $id . '" stdoff="' . $stdoff . '" dayoff="' . $dayoff . '" />' . '<urn1:locale>' . $locale . '</urn1:locale>' . '<urn1:cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<urn1:header n="' . $name . '" />' . '</urn1:SearchRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Exemple #2
0
 public function testSortBy()
 {
     $values = array('none', 'dateAsc', 'dateDesc', 'subjAsc', 'subjDesc', 'nameAsc', 'nameDesc', 'rcptAsc', 'rcptDesc', 'attachAsc', 'attachDesc', 'flagAsc', 'flagDesc', 'priorityAsc', 'priorityDesc');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\SortBy::has($value));
     }
 }
Exemple #3
0
 public function testSearchConv()
 {
     $header = new \Zimbra\Struct\AttributeName('attribute-name');
     $tz = $this->getTz();
     $cursor = new \Zimbra\Struct\CursorInfo('id', 'sortVal', 'endSortVal', true);
     $this->_api->searchConv('cid', true, 'query', array($header), $tz, 'locale', $cursor, true, true, 'allowableTaskStatus', 10, 10, true, 'types', 'groupBy', true, SortBy::DATE_ASC(), 'fetch', true, 10, true, true, true, true, true, 'resultMode', 'field', 10, 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:SearchConvRequest includeTagDeleted="true" includeTagMuted="true" allowableTaskStatus="allowableTaskStatus" calExpandInstStart="10" calExpandInstEnd="10" inDumpster="true" types="types" groupBy="groupBy" quick="true" sortBy="dateAsc" fetch="fetch" read="true" max="10" html="true" needExp="true" neuter="true" recip="true" prefetch="true" resultMode="resultMode" field="field" limit="10" offset="10" cid="cid" nest="true">' . '<urn1:query>query</urn1:query>' . '<urn1:tz id="id" stdoff="10" dayoff="10" stdname="stdname" dayname="dayname">' . '<urn1:standard mon="12" hour="2" min="3" sec="4" />' . '<urn1:daylight mon="4" hour="3" min="2" sec="10" />' . '</urn1:tz>' . '<urn1:locale>locale</urn1:locale>' . '<urn1:cursor id="id" sortVal="sortVal" endSortVal="endSortVal" includeOffset="true" />' . '<urn1:header n="attribute-name" />' . '</urn1:SearchConvRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Exemple #4
0
 public function testSearchGal()
 {
     $id = md5(self::randomString());
     $sortVal = md5(self::randomString());
     $endSortVal = md5(self::randomString());
     $cursor = new \Zimbra\Struct\CursorInfo($id, $sortVal, $endSortVal, true);
     $attr = self::randomName();
     $value = md5(self::randomString());
     $cond = new \Zimbra\Struct\EntrySearchFilterSingleCond($attr, CondOp::EQ(), $value, true);
     $singleCond = new \Zimbra\Struct\EntrySearchFilterSingleCond($attr, CondOp::GE(), $value, false);
     $multiConds = new \Zimbra\Struct\EntrySearchFilterMultiCond(false, true, array($singleCond));
     $conds = new \Zimbra\Struct\EntrySearchFilterMultiCond(true, false, array($cond, $multiConds));
     $filter = new \Zimbra\Struct\EntrySearchFilterInfo($conds);
     $locale = self::randomName();
     $ref = self::randomName();
     $name = self::randomName();
     $galAcctId = self::randomName();
     $limit = mt_rand(1, 100);
     $offset = mt_rand(0, 100);
     $this->_api->searchGal($locale, $cursor, $filter, $ref, $name, SearchType::ALL(), true, false, MemberOf::ALL(), true, $galAcctId, false, SortBy::NONE(), $limit, $offset);
     $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:zimbraAccount">' . '<env:Body>' . '<urn1:SearchGalRequest ref="' . $ref . '" name="' . $name . '" type="' . SearchType::ALL() . '" needExp="true" needIsOwner="false" needIsMember="' . MemberOf::ALL() . '" needSMIMECerts="true" galAcctId="' . $galAcctId . '" quick="false" sortBy="' . SortBy::NONE() . '" limit="' . $limit . '" offset="' . $offset . '">' . '<urn1:locale>' . $locale . '</urn1:locale>' . '<urn1:cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<urn1:searchFilter>' . '<urn1:conds not="true" or="false">' . '<urn1:conds not="false" or="true">' . '<urn1:cond attr="' . $attr . '" op="' . CondOp::GE() . '" value="' . $value . '" not="false" />' . '</urn1:conds>' . '<urn1:cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</urn1:conds>' . '</urn1:searchFilter>' . '</urn1:SearchGalRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $filter = new \Zimbra\Struct\EntrySearchFilterInfo($cond);
     $this->_api->searchGal($locale, $cursor, $filter, $ref, $name, SearchType::ALL(), true, false, MemberOf::ALL(), true, $galAcctId, false, SortBy::NONE(), $limit, $offset);
     $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:zimbraAccount">' . '<env:Body>' . '<urn1:SearchGalRequest ref="' . $ref . '" name="' . $name . '" type="' . SearchType::ALL() . '" needExp="true" needIsOwner="false" needIsMember="' . MemberOf::ALL() . '" needSMIMECerts="true" galAcctId="' . $galAcctId . '" quick="false" sortBy="' . SortBy::NONE() . '" limit="' . $limit . '" offset="' . $offset . '">' . '<urn1:locale>' . $locale . '</urn1:locale>' . '<urn1:cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<urn1:searchFilter>' . '<urn1:cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</urn1:searchFilter>' . '</urn1:SearchGalRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testSearchGal()
 {
     $id = md5(self::randomString());
     $sortVal = md5(self::randomString());
     $endSortVal = md5(self::randomString());
     $cursor = new \Zimbra\Struct\CursorInfo($id, $sortVal, $endSortVal, true);
     $attr = self::randomName();
     $value = md5(self::randomString());
     $cond = new \Zimbra\Struct\EntrySearchFilterSingleCond($attr, CondOp::EQ(), $value, true);
     $singleCond = new \Zimbra\Struct\EntrySearchFilterSingleCond($attr, CondOp::GE(), $value, false);
     $multiConds = new \Zimbra\Struct\EntrySearchFilterMultiCond(false, true, [$singleCond]);
     $conds = new \Zimbra\Struct\EntrySearchFilterMultiCond(true, false, [$cond, $multiConds]);
     $filter = new \Zimbra\Struct\EntrySearchFilterInfo($conds);
     $locale = self::randomName();
     $ref = self::randomName();
     $name = self::randomName();
     $galAcctId = self::randomName();
     $limit = mt_rand(1, 100);
     $offset = mt_rand(0, 100);
     $req = new \Zimbra\Account\Request\SearchGal($locale, $cursor, $filter, $ref, $name, SearchType::ALL(), true, false, MemberOf::ALL(), true, $galAcctId, false, SortBy::NONE(), $limit, $offset);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame($cursor, $req->getCursor());
     $this->assertSame($filter, $req->getSearchFilter());
     $this->assertSame($locale, $req->getLocale());
     $this->assertSame($ref, $req->getRef());
     $this->assertSame($name, $req->getName());
     $this->assertSame('all', $req->getType()->value());
     $this->assertTrue($req->getNeedExp());
     $this->assertFalse($req->getNeedIsOwner());
     $this->assertSame('all', $req->getNeedIsMember()->value());
     $this->assertTrue($req->getNeedSMIMECerts());
     $this->assertSame($galAcctId, $req->getGalAccountId());
     $this->assertFalse($req->getQuick());
     $this->assertSame('none', $req->getSortBy()->value());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $req->setLocale($locale)->setCursor($cursor)->setSearchFilter($filter)->setRef($ref)->setName($name)->setType(SearchType::ACCOUNT())->setNeedExp(true)->setNeedIsOwner(true)->setNeedIsMember(MemberOf::DIRECT_ONLY())->setNeedSMIMECerts(true)->setGalAccountId($galAcctId)->setQuick(true)->setSortBy(SortBy::DATE_ASC())->setLimit($limit)->setOffset($offset);
     $this->assertSame($cursor, $req->getCursor());
     $this->assertSame($filter, $req->getSearchFilter());
     $this->assertSame($locale, $req->getLocale());
     $this->assertSame($ref, $req->getRef());
     $this->assertSame($name, $req->getName());
     $this->assertSame('account', $req->getType()->value());
     $this->assertTrue($req->getNeedExp());
     $this->assertTrue($req->getNeedIsOwner());
     $this->assertSame('directOnly', $req->getNeedIsMember()->value());
     $this->assertTrue($req->getNeedSMIMECerts());
     $this->assertSame($galAcctId, $req->getGalAccountId());
     $this->assertTrue($req->getQuick());
     $this->assertSame('dateAsc', $req->getSortBy()->value());
     $this->assertSame($limit, $req->getLimit());
     $this->assertSame($offset, $req->getOffset());
     $xml = '<?xml version="1.0"?>' . "\n" . '<SearchGalRequest ref="' . $ref . '" name="' . $name . '" type="' . SearchType::ACCOUNT() . '" needExp="true" needIsOwner="true" needIsMember="' . MemberOf::DIRECT_ONLY() . '" needSMIMECerts="true" galAcctId="' . $galAcctId . '" quick="true" sortBy="' . SortBy::DATE_ASC() . '" limit="' . $limit . '" offset="' . $offset . '">' . '<locale>' . $locale . '</locale>' . '<cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<searchFilter>' . '<conds not="true" or="false">' . '<conds not="false" or="true">' . '<cond attr="' . $attr . '" op="' . CondOp::GE() . '" value="' . $value . '" not="false" />' . '</conds>' . '<cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</conds>' . '</searchFilter>' . '</SearchGalRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['SearchGalRequest' => ['_jsns' => 'urn:zimbraAccount', 'locale' => $locale, 'ref' => $ref, 'name' => $name, 'type' => SearchType::ACCOUNT()->value(), 'needExp' => true, 'needIsOwner' => true, 'needIsMember' => MemberOf::DIRECT_ONLY()->value(), 'needSMIMECerts' => true, 'galAcctId' => $galAcctId, 'quick' => true, 'sortBy' => SortBy::DATE_ASC()->value(), 'limit' => $limit, 'offset' => $offset, 'cursor' => ['id' => $id, 'sortVal' => $sortVal, 'endSortVal' => $endSortVal, 'includeOffset' => true], 'searchFilter' => ['conds' => ['not' => true, 'or' => false, 'conds' => [['not' => false, 'or' => true, 'cond' => [['attr' => $attr, 'op' => CondOp::GE()->value(), 'value' => $value, 'not' => false]]]], 'cond' => [['attr' => $attr, 'op' => CondOp::EQ()->value(), 'value' => $value, 'not' => true]]]]]];
     $this->assertEquals($array, $req->toArray());
 }
 public function testSearchConv()
 {
     $header = new \Zimbra\Struct\AttributeName('attribute-name');
     $tz = $this->getTz();
     $cursor = new \Zimbra\Struct\CursorInfo('id', 'sortVal', 'endSortVal', true);
     $req = new \Zimbra\Mail\Request\SearchConv('cid', true, 'query', array($header), $tz, 'locale', $cursor, true, true, 'allowableTaskStatus', 10, 10, true, 'types', 'groupBy', true, SortBy::DATE_ASC(), 'fetch', true, 10, true, true, true, true, true, 'resultMode', 'field', 10, 10);
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\MailSearchParams', $req);
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame('cid', $req->cid());
     $this->assertTrue($req->nest());
     $req->cid('cid')->nest(true);
     $this->assertSame('cid', $req->cid());
     $this->assertTrue($req->nest());
     $xml = '<?xml version="1.0"?>' . "\n" . '<SearchConvRequest includeTagDeleted="true" includeTagMuted="true" allowableTaskStatus="allowableTaskStatus" calExpandInstStart="10" calExpandInstEnd="10" inDumpster="true" types="types" groupBy="groupBy" quick="true" sortBy="dateAsc" fetch="fetch" read="true" max="10" html="true" needExp="true" neuter="true" recip="true" prefetch="true" resultMode="resultMode" field="field" limit="10" offset="10" cid="cid" nest="true">' . '<query>query</query>' . '<tz id="id" stdoff="10" dayoff="10" stdname="stdname" dayname="dayname">' . '<standard mon="12" hour="2" min="3" sec="4" />' . '<daylight mon="4" hour="3" min="2" sec="10" />' . '</tz>' . '<locale>locale</locale>' . '<cursor id="id" sortVal="sortVal" endSortVal="endSortVal" includeOffset="true" />' . '<header n="attribute-name" />' . '</SearchConvRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('SearchConvRequest' => array('_jsns' => 'urn:zimbraMail', 'query' => 'query', 'header' => array(array('n' => 'attribute-name')), 'tz' => array('id' => 'id', 'stdoff' => 10, 'dayoff' => 10, 'stdname' => 'stdname', 'dayname' => 'dayname', 'standard' => array('mon' => 12, 'hour' => 2, 'min' => 3, 'sec' => 4), 'daylight' => array('mon' => 4, 'hour' => 3, 'min' => 2, 'sec' => 10)), 'locale' => 'locale', 'cursor' => array('id' => 'id', 'sortVal' => 'sortVal', 'endSortVal' => 'endSortVal', 'includeOffset' => true), 'cid' => 'cid', 'nest' => true, 'includeTagDeleted' => true, 'includeTagMuted' => true, 'allowableTaskStatus' => 'allowableTaskStatus', 'calExpandInstStart' => 10, 'calExpandInstEnd' => 10, 'inDumpster' => true, 'types' => 'types', 'groupBy' => 'groupBy', 'quick' => true, 'sortBy' => 'dateAsc', 'fetch' => 'fetch', 'read' => true, 'max' => 10, 'html' => true, 'needExp' => true, 'neuter' => true, 'recip' => true, 'prefetch' => true, 'resultMode' => 'resultMode', 'field' => 'field', 'limit' => 10, 'offset' => 10));
     $this->assertEquals($array, $req->toArray());
 }