/**
  * Sets types
  *
  * @param  string $types
  * @return self
  */
 public function setTypes($types)
 {
     $arrType = [];
     $types = explode(',', trim($types));
     foreach ($types as $type) {
         $type = trim($type);
         if (ReindexType::has($type) && !in_array($type, $arrType)) {
             $arrType[] = trim($type);
         }
     }
     return $this->setProperty('types', implode(',', $arrType));
 }
Example #2
0
 public function testReIndexApi()
 {
     $id = $this->faker->word;
     $ids = $this->faker->word;
     $enums = $this->faker->randomElements(ReindexType::enums(), mt_rand(1, count(ReindexType::enums())));
     $types = implode(',', $enums);
     $mbox = new ReindexMailboxInfo($id, $types, $ids);
     $this->api->reIndex($mbox, ReIndexAction::CANCEL());
     $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:ReIndexRequest action="' . ReIndexAction::CANCEL() . '">' . '<urn1:mbox id="' . $id . '" types="' . $types . '" ids="' . $ids . '" />' . '</urn1:ReIndexRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testReindexMailboxInfo()
 {
     $id = $this->faker->word;
     $ids = $this->faker->word;
     $enums = $this->faker->randomElements(ReindexType::enums(), mt_rand(1, count(ReindexType::enums())));
     $types = implode(',', $enums);
     $mbox = new ReindexMailboxInfo($id, $types, $ids);
     $this->assertSame($id, $mbox->getId());
     $this->assertSame($types, $mbox->getTypes());
     $this->assertSame($ids, $mbox->getIds());
     $mbox->setId($id)->setTypes($types)->setIds($ids);
     $this->assertSame($id, $mbox->getId());
     $this->assertSame($types, $mbox->getTypes());
     $this->assertSame($ids, $mbox->getIds());
     $xml = '<?xml version="1.0"?>' . "\n" . '<mbox id="' . $id . '" types="' . $types . '" ids="' . $ids . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $mbox);
     $array = ['mbox' => ['id' => $id, 'types' => $types, 'ids' => $ids]];
     $this->assertEquals($array, $mbox->toArray());
 }
Example #4
0
 public function testReindexType()
 {
     $values = array('conversation', 'message', 'contact', 'appointment', 'task', 'note', 'wiki', 'document');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\ReindexType::has($value));
     }
 }
Example #5
0
 public function testReIndex()
 {
     $id = self::randomName();
     $ids = self::randomName();
     $types = self::randomAttrs(\Zimbra\Enum\ReindexType::enums());
     $mbox = new \Zimbra\Admin\Struct\ReindexMailboxInfo($id, $types, $ids);
     $this->_api->reIndex($mbox, ReIndexAction::CANCEL());
     $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:ReIndexRequest action="' . ReIndexAction::CANCEL() . '">' . '<urn1:mbox id="' . $id . '" types="' . $types . '" ids="' . $ids . '" />' . '</urn1:ReIndexRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #6
0
 public function testReindexMailboxInfo()
 {
     $id = self::randomName();
     $ids = self::randomName();
     $types = self::randomAttrs(\Zimbra\Enum\ReindexType::enums());
     $mbox = new \Zimbra\Admin\Struct\ReindexMailboxInfo($id, $types, $ids);
     $this->assertSame($id, $mbox->getId());
     $this->assertSame($types, $mbox->getTypes());
     $this->assertSame($ids, $mbox->getIds());
     $mbox->setId($id)->setTypes($types)->setIds($ids);
     $this->assertSame($id, $mbox->getId());
     $this->assertSame($types, $mbox->getTypes());
     $this->assertSame($ids, $mbox->getIds());
     $xml = '<?xml version="1.0"?>' . "\n" . '<mbox id="' . $id . '" types="' . $types . '" ids="' . $ids . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $mbox);
     $array = ['mbox' => ['id' => $id, 'types' => $types, 'ids' => $ids]];
     $this->assertEquals($array, $mbox->toArray());
 }
Example #7
0
 public function testReIndex()
 {
     $id = self::randomName();
     $ids = self::randomName();
     $types = self::randomAttrs(\Zimbra\Enum\ReindexType::enums());
     $mbox = new \Zimbra\Admin\Struct\ReindexMailboxInfo($id, $types, $ids);
     $req = new \Zimbra\Admin\Request\ReIndex($mbox, ReIndexAction::START());
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertEquals($mbox, $req->getMailbox());
     $this->assertEquals('start', $req->getAction()->value());
     $req->setMailbox($mbox)->setAction(ReIndexAction::CANCEL());
     $this->assertEquals($mbox, $req->getMailbox());
     $this->assertEquals('cancel', $req->getAction()->value());
     $xml = '<?xml version="1.0"?>' . "\n" . '<ReIndexRequest action="' . ReIndexAction::CANCEL() . '">' . '<mbox id="' . $id . '" types="' . $types . '" ids="' . $ids . '" />' . '</ReIndexRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['ReIndexRequest' => ['_jsns' => 'urn:zimbraAdmin', 'action' => ReIndexAction::CANCEL()->value(), 'mbox' => ['id' => $id, 'types' => $types, 'ids' => $ids]]];
     $this->assertEquals($array, $req->toArray());
 }