public function testDocumentActionSelector()
 {
     $expiry = mt_rand(1, 100);
     $grant = new DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), $expiry);
     $zid = $this->faker->uuid;
     $id = $this->faker->uuid;
     $tcon = $this->faker->word;
     $tag = mt_rand(1, 100);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(1, 127);
     $name = $this->faker->word;
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $action = new DocumentActionSelector(DocumentActionOp::WATCH(), $grant, $zid, $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames);
     $this->assertTrue($action->getOperation()->is('watch'));
     $this->assertSame($grant, $action->getGrant());
     $this->assertSame($zid, $action->getZimbraId());
     $action->setOperation(DocumentActionOp::WATCH())->setGrant($grant)->setZimbraId($zid);
     $this->assertTrue($action->getOperation()->is('watch'));
     $this->assertSame($grant, $action->getGrant());
     $this->assertSame($zid, $action->getZimbraId());
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . DocumentActionOp::WATCH() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '" zid="' . $zid . '">' . '<grant perm="' . DocumentPermission::READ() . '" gt="' . DocumentGrantType::ALL() . '" expiry="' . $expiry . '" />' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => DocumentActionOp::WATCH()->value(), 'id' => $id, 'tcon' => $tcon, 'tag' => $tag, 'l' => $folder, 'rgb' => $rgb, 'color' => $color, 'name' => $name, 'f' => $flags, 't' => $tags, 'tn' => $tagNames, 'zid' => $zid, 'grant' => array('perm' => DocumentPermission::READ()->value(), 'gt' => DocumentGrantType::ALL()->value(), 'expiry' => $expiry)));
     $this->assertEquals($array, $action->toArray());
 }
Exemplo n.º 2
0
 public function testDocumentActionGrant()
 {
     $expiry = mt_rand(1, 100);
     $grant = new DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), $expiry);
     $this->assertTrue($grant->getRights()->is('r'));
     $this->assertTrue($grant->getGrantType()->is('all'));
     $this->assertSame($expiry, $grant->getExpiry());
     $grant->setRights(DocumentPermission::READ())->setGrantType(DocumentGrantType::ALL())->setExpiry($expiry);
     $this->assertTrue($grant->getRights()->is('r'));
     $this->assertTrue($grant->getGrantType()->is('all'));
     $this->assertSame($expiry, $grant->getExpiry());
     $xml = '<?xml version="1.0"?>' . "\n" . '<grant perm="' . DocumentPermission::READ() . '" gt="' . DocumentGrantType::ALL() . '" expiry="' . $expiry . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $grant);
     $array = array('grant' => array('perm' => DocumentPermission::READ()->value(), 'gt' => DocumentGrantType::ALL()->value(), 'expiry' => $expiry));
     $this->assertEquals($array, $grant->toArray());
 }
Exemplo n.º 3
0
 public function testDocumentActionApi()
 {
     $zid = $this->faker->uuid;
     $id = $this->faker->uuid;
     $tcon = $this->faker->word;
     $tag = mt_rand(1, 100);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(1, 127);
     $name = $this->faker->word;
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $expiry = mt_rand(1, 100);
     $grant = new DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), $expiry);
     $action = new DocumentActionSelector(DocumentActionOp::WATCH(), $grant, $zid, $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames);
     $this->api->documentAction($action);
     $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:DocumentActionRequest>' . '<urn1:action op="' . DocumentActionOp::WATCH() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '" zid="' . $zid . '">' . '<urn1:grant perm="' . DocumentPermission::READ() . '" gt="' . DocumentGrantType::ALL() . '" expiry="' . $expiry . '" />' . '</urn1:action>' . '</urn1:DocumentActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Exemplo n.º 4
0
 public function testDocumentGrantType()
 {
     $values = array('all', 'pub');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\DocumentGrantType::has($value));
     }
 }
Exemplo n.º 5
0
 public function testDocumentAction()
 {
     $grant = new \Zimbra\Mail\Struct\DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), 10);
     $action = new \Zimbra\Mail\Struct\DocumentActionSelector(DocumentActionOp::WATCH(), $grant, 'zid', 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn');
     $this->_api->documentAction($action);
     $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:DocumentActionRequest>' . '<urn1:action op="watch" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn" zid="zid">' . '<urn1:grant perm="r" gt="all" expiry="10" />' . '</urn1:action>' . '</urn1:DocumentActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Exemplo n.º 6
0
 public function testDocumentActionSelector()
 {
     $grant = new \Zimbra\Mail\Struct\DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), 10);
     $action = new \Zimbra\Mail\Struct\DocumentActionSelector(DocumentActionOp::WATCH(), $grant, 'zid', 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn');
     $this->assertTrue($action->op()->is('watch'));
     $this->assertSame($grant, $action->grant());
     $this->assertSame('zid', $action->zid());
     $action->op(DocumentActionOp::WATCH())->grant($grant)->zid('zid');
     $this->assertTrue($action->op()->is('watch'));
     $this->assertSame($grant, $action->grant());
     $this->assertSame('zid', $action->zid());
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="watch" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn" zid="zid">' . '<grant perm="r" gt="all" expiry="10" />' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => 'watch', 'id' => 'id', 'tcon' => 'tcon', 'tag' => 10, 'l' => 'l', 'rgb' => '#aabbcc', 'color' => 10, 'name' => 'name', 'f' => 'f', 't' => 't', 'tn' => 'tn', 'zid' => 'zid', 'grant' => array('perm' => 'r', 'gt' => 'all', 'expiry' => 10)));
     $this->assertEquals($array, $action->toArray());
 }
Exemplo n.º 7
0
 public function testDocumentAction()
 {
     $grant = new \Zimbra\Mail\Struct\DocumentActionGrant(DocumentPermission::READ(), DocumentGrantType::ALL(), 10);
     $action = new \Zimbra\Mail\Struct\DocumentActionSelector(DocumentActionOp::WATCH(), $grant, 'zid', 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn');
     $req = new \Zimbra\Mail\Request\DocumentAction($action);
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame($action, $req->action());
     $req->action($action);
     $this->assertSame($action, $req->action());
     $xml = '<?xml version="1.0"?>' . "\n" . '<DocumentActionRequest>' . '<action op="watch" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn" zid="zid">' . '<grant perm="r" gt="all" expiry="10" />' . '</action>' . '</DocumentActionRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('DocumentActionRequest' => array('_jsns' => 'urn:zimbraMail', 'action' => array('op' => 'watch', 'id' => 'id', 'tcon' => 'tcon', 'tag' => 10, 'l' => 'l', 'rgb' => '#aabbcc', 'color' => 10, 'name' => 'name', 'f' => 'f', 't' => 't', 'tn' => 'tn', 'zid' => 'zid', 'grant' => array('perm' => 'r', 'gt' => 'all', 'expiry' => 10))));
     $this->assertEquals($array, $req->toArray());
 }