public function testSearchCalendarResourcesApi()
 {
     $attr = $this->faker->word;
     $value = $this->faker->word;
     $domain = $this->faker->word;
     $sortBy = $this->faker->word;
     $attrs = $this->faker->word;
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $cond = new SingleCond($attr, CondOp::EQ(), $value, true);
     $singleCond = new SingleCond($attr, CondOp::GE(), $value, false);
     $multiConds = new MultiCond(false, true, [$singleCond]);
     $conds = new MultiCond(true, false, [$cond, $multiConds]);
     $searchFilter = new FilterInfo($conds);
     $this->api->searchCalendarResources($searchFilter, $limit, $offset, $domain, true, $sortBy, false, [$attrs]);
     $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:SearchCalendarResourcesRequest ' . 'limit="' . $limit . '" ' . 'offset="' . $offset . '" ' . 'domain="' . $domain . '" ' . 'applyCos="true" ' . 'sortBy="' . $sortBy . '" ' . 'sortAscending="false" ' . 'attrs="' . $attrs . '">' . '<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:SearchCalendarResourcesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $searchFilter = new FilterInfo($cond);
     $this->api->searchCalendarResources($searchFilter, $limit, $offset, $domain, true, $sortBy, false, [$attrs]);
     $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:SearchCalendarResourcesRequest ' . 'limit="' . $limit . '" ' . 'offset="' . $offset . '" ' . 'domain="' . $domain . '" ' . 'applyCos="true" ' . 'sortBy="' . $sortBy . '" ' . 'sortAscending="false" ' . 'attrs="' . $attrs . '">' . '<urn1:searchFilter>' . '<urn1:cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</urn1:searchFilter>' . '</urn1:SearchCalendarResourcesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testEntrySearchFilterInfo()
 {
     $attr = $this->faker->word;
     $value = $this->faker->word;
     $cond = new EntrySearchFilterSingleCond($attr, CondOp::EQ(), $value, true);
     $singleCond = new EntrySearchFilterSingleCond($attr, CondOp::GE(), $value, false);
     $multiConds = new EntrySearchFilterMultiCond(false, true, [$singleCond]);
     $conds = new EntrySearchFilterMultiCond(true, false, [$cond, $multiConds]);
     $filter = new EntrySearchFilterInfo($conds);
     $this->assertSame($conds, $filter->getCondition());
     $filter->setCondition($conds);
     $this->assertSame($conds, $filter->getCondition());
     $xml = '<?xml version="1.0"?>' . "\n" . '<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>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $filter);
     $array = ['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, $filter->toArray());
     $filter = new EntrySearchFilterInfo($cond);
     $this->assertSame($cond, $filter->getCondition());
     $filter->setCondition($cond);
     $this->assertSame($cond, $filter->getCondition());
     $xml = '<?xml version="1.0"?>' . "\n" . '<searchFilter>' . '<cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</searchFilter>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $filter);
     $array = ['searchFilter' => ['cond' => ['attr' => $attr, 'op' => CondOp::EQ()->value(), 'value' => $value, 'not' => true]]];
     $this->assertEquals($array, $filter->toArray());
 }
 public function testEntrySearchFilterSingleCond()
 {
     $attr = $this->faker->word;
     $value = $this->faker->word;
     $cond = new EntrySearchFilterSingleCond($attr, CondOp::GE(), $value, false);
     $this->assertSame($attr, $cond->getAttr());
     $this->assertTrue($cond->getOp()->is('ge'));
     $this->assertSame($value, $cond->getValue());
     $this->assertFalse($cond->getNot());
     $cond->setAttr($attr)->setOp(CondOp::EQ())->setValue($value)->setNot(true);
     $this->assertSame($attr, $cond->getAttr());
     $this->assertTrue($cond->getOp()->is('eq'));
     $this->assertSame($value, $cond->getValue());
     $this->assertTrue($cond->getNot());
     $xml = '<?xml version="1.0"?>' . "\n" . '<cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $cond);
     $array = ['cond' => ['attr' => $attr, 'op' => CondOp::EQ()->value(), 'value' => $value, 'not' => true]];
     $this->assertEquals($array, $cond->toArray());
 }
예제 #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 testSearchCalendarResourcesApi()
 {
     $id = $this->faker->word;
     $sortVal = $this->faker->word;
     $endSortVal = $this->faker->word;
     $cursor = new CursorInfo($id, $sortVal, $endSortVal, true);
     $attr = $this->faker->word;
     $value = $this->faker->word;
     $cond = new SingleCond($attr, CondOp::EQ(), $value, true);
     $singleCond = new SingleCond($attr, CondOp::GE(), $value, false);
     $multiConds = new MultiCond(false, true, [$singleCond]);
     $conds = new MultiCond(true, false, [$cond, $multiConds]);
     $filter = new FilterInfo($conds);
     $locale = $this->faker->word;
     $name = $this->faker->word;
     $sortBy = $this->faker->word;
     $galAcctId = $this->faker->word;
     $attrs = $this->faker->word;
     $limit = mt_rand(1, 100);
     $offset = mt_rand(0, 100);
     $this->api->searchCalendarResources($locale, $cursor, $name, $filter, true, $sortBy, $limit, $offset, $galAcctId, [$attrs]);
     $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:SearchCalendarResourcesRequest quick="true" sortBy="' . $sortBy . '" limit="' . $limit . '" offset="' . $offset . '" galAcctId="' . $galAcctId . '" attrs="' . $attrs . '">' . '<urn1:locale>' . $locale . '</urn1:locale>' . '<urn1:cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<urn1:name>' . $name . '</urn1:name>' . '<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:SearchCalendarResourcesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $filter = new FilterInfo($cond);
     $this->api->searchCalendarResources($locale, $cursor, $name, $filter, true, $sortBy, $limit, $offset, $galAcctId, [$attrs]);
     $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:SearchCalendarResourcesRequest quick="true" sortBy="' . $sortBy . '" limit="' . $limit . '" offset="' . $offset . '" galAcctId="' . $galAcctId . '" attrs="' . $attrs . '">' . '<urn1:locale>' . $locale . '</urn1:locale>' . '<urn1:cursor id="' . $id . '" sortVal="' . $sortVal . '" endSortVal="' . $endSortVal . '" includeOffset="true" />' . '<urn1:name>' . $name . '</urn1:name>' . '<urn1:searchFilter>' . '<urn1:cond attr="' . $attr . '" op="' . CondOp::EQ() . '" value="' . $value . '" not="true" />' . '</urn1:searchFilter>' . '</urn1:SearchCalendarResourcesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
예제 #6
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, [$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());
 }
예제 #7
0
 public function testSearchCalendarResources()
 {
     $attr = self::randomName();
     $value = self::randomName();
     $domain = self::randomName();
     $sortBy = self::randomName();
     $attrs = self::randomName();
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $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]);
     $searchFilter = new \Zimbra\Struct\EntrySearchFilterInfo($conds);
     $req = new \Zimbra\Admin\Request\SearchCalendarResources($searchFilter, $limit, $offset, $domain, false, $sortBy, true, [$attrs]);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertEquals($searchFilter, $req->getSearchFilter());
     $this->assertEquals($limit, $req->getLimit());
     $this->assertEquals($offset, $req->getOffset());
     $this->assertEquals($domain, $req->getDomain());
     $this->assertFalse($req->getApplyCos());
     $this->assertEquals($sortBy, $req->getSortBy());
     $this->assertTrue($req->getSortAscending());
     $req->setSearchFilter($searchFilter)->setLimit($limit)->setOffset($offset)->setDomain($domain)->setApplyCos(true)->setSortBy($sortBy)->setSortAscending(false);
     $this->assertEquals($searchFilter, $req->getSearchFilter());
     $this->assertEquals($limit, $req->getLimit());
     $this->assertEquals($offset, $req->getOffset());
     $this->assertEquals($domain, $req->getDomain());
     $this->assertTrue($req->getApplyCos());
     $this->assertEquals($sortBy, $req->getSortBy());
     $this->assertFalse($req->getSortAscending());
     $xml = '<?xml version="1.0"?>' . "\n" . '<SearchCalendarResourcesRequest ' . 'limit="' . $limit . '" ' . 'offset="' . $offset . '" ' . 'domain="' . $domain . '" ' . 'applyCos="true" ' . 'sortBy="' . $sortBy . '" ' . 'sortAscending="false" ' . 'attrs="' . $attrs . '">' . '<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>' . '</SearchCalendarResourcesRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['SearchCalendarResourcesRequest' => ['_jsns' => 'urn:zimbraAdmin', 'limit' => $limit, 'offset' => $offset, 'domain' => $domain, 'applyCos' => true, 'sortBy' => $sortBy, 'sortAscending' => false, 'attrs' => $attrs, '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());
 }