public function testAutoCompleteApi() { $name = $this->faker->word; $folders = $this->faker->word; $this->api->autoComplete($name, GalSearchType::ALL(), true, $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:AutoCompleteRequest name="' . $name . '" t="' . GalSearchType::ALL() . '" needExp="true" folders="' . $folders . '" includeGal="true" />' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testAutoCompleteGalApi() { $name = $this->faker->word; $id = $this->faker->word; $limit = mt_rand(0, 100); $this->api->autoCompleteGal($name, true, SearchType::ALL(), $id, $limit); $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:AutoCompleteGalRequest ' . 'needExp="true" name="' . $name . '" type="' . SearchType::ALL() . '" galAcctId="' . $id . '" limit="' . $limit . '" />' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testSearchGalRequest() { $domain = $this->faker->word; $name = $this->faker->word; $galAcctId = $this->faker->word; $limit = mt_rand(0, 100); $req = new SearchGal($domain, $name, $limit, GalSearchType::ALL(), $galAcctId); $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req); $this->assertEquals($domain, $req->getDomain()); $this->assertEquals($name, $req->getName()); $this->assertEquals($limit, $req->getLimit()); $this->assertEquals('all', $req->getType()->value()); $this->assertEquals($galAcctId, $req->getGalAccounttId()); $req->setDomain($domain)->setName($name)->setLimit($limit)->setType(GalSearchType::ACCOUNT())->setGalAccounttId($galAcctId); $this->assertEquals($domain, $req->getDomain()); $this->assertEquals($name, $req->getName()); $this->assertEquals($limit, $req->getLimit()); $this->assertEquals('account', $req->getType()->value()); $this->assertEquals($galAcctId, $req->getGalAccounttId()); $xml = '<?xml version="1.0"?>' . "\n" . '<SearchGalRequest ' . 'domain="' . $domain . '" ' . 'name="' . $name . '" ' . 'limit="' . $limit . '" ' . 'type="' . GalSearchType::ACCOUNT() . '" ' . 'galAcctId="' . $galAcctId . '" ' . '/>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['SearchGalRequest' => ['_jsns' => 'urn:zimbraAdmin', 'domain' => $domain, 'name' => $name, 'limit' => $limit, 'type' => GalSearchType::ACCOUNT()->value(), 'galAcctId' => $galAcctId]]; $this->assertEquals($array, $req->toArray()); }
public function testAutoComplete() { $this->_api->autoComplete('name', GalSearchType::ALL(), true, 'folders', true); $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:AutoCompleteRequest name="name" t="all" needExp="true" folders="folders" includeGal="true" />' . '</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, 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 testAutoComplete() { $req = new \Zimbra\Mail\Request\AutoComplete('name', GalSearchType::ALL(), true, 'folders', true); $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req); $this->assertSame('name', $req->name()); $this->assertTrue($req->t()->is('all')); $this->assertTrue($req->needExp()); $this->assertSame('folders', $req->folders()); $this->assertTrue($req->includeGal()); $req->name('name')->t(GalSearchType::ALL())->needExp(true)->folders('folders')->includeGal(true); $this->assertSame('name', $req->name()); $this->assertTrue($req->t()->is('all')); $this->assertTrue($req->needExp()); $this->assertSame('folders', $req->folders()); $this->assertTrue($req->includeGal()); $xml = '<?xml version="1.0"?>' . "\n" . '<AutoCompleteRequest name="name" t="all" needExp="true" folders="folders" includeGal="true" />'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = array('AutoCompleteRequest' => array('_jsns' => 'urn:zimbraMail', 'name' => 'name', 't' => 'all', 'needExp' => true, 'folders' => 'folders', 'includeGal' => true)); $this->assertEquals($array, $req->toArray()); }