示例#1
0
 public function testSearchGalRequest()
 {
     $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;
     $ref = $this->faker->word;
     $name = $this->faker->word;
     $galAcctId = $this->faker->word;
     $limit = mt_rand(1, 100);
     $offset = mt_rand(0, 100);
     $req = new 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());
 }
示例#2
0
 public function testSearchGalApi()
 {
     $domain = $this->faker->word;
     $name = $this->faker->word;
     $galAcctId = $this->faker->word;
     $limit = mt_rand(0, 100);
     $this->api->searchGal($domain, $name, $limit, GalSearchType::ACCOUNT(), $galAcctId);
     $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:SearchGalRequest ' . 'domain="' . $domain . '" ' . 'name="' . $name . '" ' . 'limit="' . $limit . '" ' . 'type="' . GalSearchType::ACCOUNT() . '" ' . 'galAcctId="' . $galAcctId . '" ' . '/>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testAutoCompleteGalRequest()
 {
     $name = $this->faker->word;
     $id = $this->faker->word;
     $limit = mt_rand(0, 100);
     $req = new AutoCompleteGal($name, true, SearchType::ALL(), $id, $limit);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame($name, $req->getName());
     $this->assertTrue($req->getNeedExp());
     $this->assertSame('all', $req->getType()->value());
     $this->assertSame($id, $req->getGalAccountId());
     $this->assertSame($limit, $req->getLimit());
     $req->setName($name)->setNeedExp(false)->setType(SearchType::ACCOUNT())->setGalAccountId($id)->setLimit($limit);
     $this->assertSame($name, $req->getName());
     $this->assertFalse($req->getNeedExp());
     $this->assertSame('account', $req->getType()->value());
     $this->assertSame($id, $req->getGalAccountId());
     $this->assertSame($limit, $req->getLimit());
     $xml = '<?xml version="1.0"?>' . "\n" . '<AutoCompleteGalRequest ' . 'needExp="false" name="' . $name . '" type="' . SearchType::ACCOUNT() . '" galAcctId="' . $id . '" limit="' . $limit . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['AutoCompleteGalRequest' => ['_jsns' => 'urn:zimbraAccount', 'name' => $name, 'needExp' => false, 'type' => SearchType::ACCOUNT()->value(), 'galAcctId' => $id, 'limit' => $limit]];
     $this->assertEquals($array, $req->toArray());
 }
示例#4
0
 public function testSearchGal()
 {
     $domain = self::randomName();
     $name = self::randomName();
     $galAcctId = self::randomName();
     $limit = mt_rand(0, 100);
     $req = new \Zimbra\Admin\Request\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());
 }