Esempio n. 1
0
 public function testMailQueueActionApi()
 {
     $value = $this->faker->word;
     $name = $this->faker->word;
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $attr = new ValueAttrib($value);
     $field = new QueueQueryField($name, [$attr]);
     $query = new QueueQuery([$field], $limit, $offset);
     $action = new MailQueueAction($query, QueueAction::HOLD(), QueueActionBy::QUERY());
     $queue = new MailQueueWithAction($action, $name);
     $server = new ServerWithQueueAction($queue, $name);
     $this->api->mailQueueAction($server);
     $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:MailQueueActionRequest>' . '<urn1:server name="' . $name . '">' . '<urn1:queue name="' . $name . '">' . '<urn1:action op="' . QueueAction::HOLD() . '" by="' . QueueActionBy::QUERY() . '">' . '<urn1:query limit="' . $limit . '" offset="' . $offset . '">' . '<urn1:field name="' . $name . '">' . '<urn1:match value="' . $value . '" />' . '</urn1:field>' . '</urn1:query>' . '</urn1:action>' . '</urn1:queue>' . '</urn1:server>' . '</urn1:MailQueueActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testMailQueueWithAction()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $attr = new ValueAttrib($value);
     $field = new QueueQueryField($name, [$attr]);
     $query = new QueueQuery([$field], $limit, $offset);
     $action = new MailQueueAction($query, QueueAction::HOLD(), QueueActionBy::QUERY());
     $queue = new MailQueueWithAction($action, $name);
     $this->assertSame($name, $queue->getName());
     $this->assertSame($action, $queue->getAction());
     $queue->setAction($action)->setName($name);
     $this->assertSame($name, $queue->getName());
     $this->assertSame($action, $queue->getAction());
     $xml = '<?xml version="1.0"?>' . "\n" . '<queue name="' . $name . '">' . '<action op="' . QueueAction::HOLD() . '" by="' . QueueActionBy::QUERY() . '">' . '<query limit="' . $limit . '" offset="' . $offset . '">' . '<field name="' . $name . '">' . '<match value="' . $value . '" />' . '</field>' . '</query>' . '</action>' . '</queue>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $queue);
     $array = ['queue' => ['name' => $name, 'action' => ['op' => QueueAction::HOLD()->value(), 'by' => QueueActionBy::QUERY()->value(), 'query' => ['limit' => $limit, 'offset' => $offset, 'field' => [['name' => $name, 'match' => [['value' => $value]]]]]]]];
     $this->assertEquals($array, $queue->toArray());
 }
Esempio n. 3
0
 public function testQueueActionBy()
 {
     $values = array('id', 'query');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\QueueActionBy::has($value));
     }
 }
Esempio n. 4
0
 public function testMailQueueAction()
 {
     $value = self::randomName();
     $name = self::randomName();
     $limit = mt_rand(0, 100);
     $offset = mt_rand(0, 100);
     $attr = new \Zimbra\Admin\Struct\ValueAttrib($value);
     $field = new \Zimbra\Admin\Struct\QueueQueryField($name, [$attr]);
     $query = new \Zimbra\Admin\Struct\QueueQuery([$field], $limit, $offset);
     $action = new \Zimbra\Admin\Struct\MailQueueAction($query, QueueAction::HOLD(), QueueActionBy::QUERY());
     $queue = new \Zimbra\Admin\Struct\MailQueueWithAction($action, $name);
     $server = new \Zimbra\Admin\Struct\ServerWithQueueAction($queue, $name);
     $req = new \Zimbra\Admin\Request\MailQueueAction($server);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($server, $req->getServer());
     $req->setServer($server);
     $this->assertSame($server, $req->getServer());
     $xml = '<?xml version="1.0"?>' . "\n" . '<MailQueueActionRequest>' . '<server name="' . $name . '">' . '<queue name="' . $name . '">' . '<action op="' . QueueAction::HOLD() . '" by="' . QueueActionBy::QUERY() . '">' . '<query limit="' . $limit . '" offset="' . $offset . '">' . '<field name="' . $name . '">' . '<match value="' . $value . '" />' . '</field>' . '</query>' . '</action>' . '</queue>' . '</server>' . '</MailQueueActionRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['MailQueueActionRequest' => ['_jsns' => 'urn:zimbraAdmin', 'server' => ['name' => $name, 'queue' => ['name' => $name, 'action' => ['op' => QueueAction::HOLD()->value(), 'by' => QueueActionBy::QUERY()->value(), 'query' => ['limit' => $limit, 'offset' => $offset, 'field' => [['name' => $name, 'match' => [['value' => $value]]]]]]]]]];
     $this->assertEquals($array, $req->toArray());
 }