public function testTagActionSelector() { $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; $lifetime = $this->faker->word; $policy = new Policy(Type::SYSTEM(), $id, $name, $lifetime); $keep = new RetentionPolicyKeep(array($policy)); $policy = new Policy(Type::USER(), $id, $name, $lifetime); $purge = new RetentionPolicyPurge(array($policy)); $retention = new RetentionPolicy($keep, $purge); $action = new TagActionSelector($retention, TagActionOp::READ(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames); $this->assertTrue($action->getOperation()->is('read')); $this->assertSame($retention, $action->getRetentionPolicy()); $action = new TagActionSelector(NULL, TagActionOp::DELETE(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames); $action->setOperation(TagActionOp::READ())->setRetentionPolicy($retention); $this->assertTrue($action->getOperation()->is('read')); $this->assertSame($retention, $action->getRetentionPolicy()); $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . TagActionOp::READ() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '">' . '<retentionPolicy>' . '<keep>' . '<policy type="' . Type::SYSTEM() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</keep>' . '<purge>' . '<policy type="' . Type::USER() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</purge>' . '</retentionPolicy>' . '</action>'; $this->assertXmlStringEqualsXmlString($xml, (string) $action); $array = array('action' => array('op' => TagActionOp::READ()->value(), 'id' => $id, 'tcon' => $tcon, 'tag' => $tag, 'l' => $folder, 'rgb' => $rgb, 'color' => $color, 'name' => $name, 'f' => $flags, 't' => $tags, 'tn' => $tagNames, 'retentionPolicy' => array('keep' => array('policy' => array(array('type' => Type::SYSTEM()->value(), 'id' => $id, 'name' => $name, 'lifetime' => $lifetime))), 'purge' => array('policy' => array(array('type' => Type::USER()->value(), 'id' => $id, 'name' => $name, 'lifetime' => $lifetime)))))); $this->assertEquals($array, $action->toArray()); }
public function testTagActionApi() { $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; $lifetime = $this->faker->word; $policy = new Policy(Type::SYSTEM(), $id, $name, $lifetime); $keep = new RetentionPolicyKeep(array($policy)); $policy = new Policy(Type::USER(), $id, $name, $lifetime); $purge = new RetentionPolicyPurge(array($policy)); $retention = new RetentionPolicy($keep, $purge); $action = new TagActionSelector($retention, TagActionOp::READ(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames); $this->api->tagAction($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:TagActionRequest>' . '<urn1:action op="' . TagActionOp::READ() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '">' . '<urn1:retentionPolicy>' . '<urn1:keep>' . '<urn1:policy type="' . Type::SYSTEM() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</urn1:keep>' . '<urn1:purge>' . '<urn1:policy type="' . Type::USER() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</urn1:purge>' . '</urn1:retentionPolicy>' . '</urn1:action>' . '</urn1:TagActionRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testTagAction() { $policy = new \Zimbra\Mail\Struct\Policy(Type::SYSTEM(), 'id', 'name', 'lifetime'); $keep = new \Zimbra\Mail\Struct\RetentionPolicyKeep(array($policy)); $policy = new \Zimbra\Mail\Struct\Policy(Type::USER(), 'id', 'name', 'lifetime'); $purge = new \Zimbra\Mail\Struct\RetentionPolicyPurge(array($policy)); $retentionPolicy = new \Zimbra\Mail\Struct\RetentionPolicy($keep, $purge); $action = new \Zimbra\Mail\Struct\TagActionSelector($retentionPolicy, TagActionOp::READ(), 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn'); $this->_api->tagAction($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:TagActionRequest>' . '<urn1:action op="read" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn">' . '<urn1:retentionPolicy>' . '<urn1:keep>' . '<urn1:policy type="system" id="id" name="name" lifetime="lifetime" />' . '</urn1:keep>' . '<urn1:purge>' . '<urn1:policy type="user" id="id" name="name" lifetime="lifetime" />' . '</urn1:purge>' . '</urn1:retentionPolicy>' . '</urn1:action>' . '</urn1:TagActionRequest>' . '</env:Body>' . '</env:Envelope>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); }
public function testTagActionSelector() { $policy = new \Zimbra\Mail\Struct\Policy(Type::SYSTEM(), 'id', 'name', 'lifetime'); $keep = new \Zimbra\Mail\Struct\RetentionPolicyKeep(array($policy)); $policy = new \Zimbra\Mail\Struct\Policy(Type::USER(), 'id', 'name', 'lifetime'); $purge = new \Zimbra\Mail\Struct\RetentionPolicyPurge(array($policy)); $retentionPolicy = new \Zimbra\Mail\Struct\RetentionPolicy($keep, $purge); $action = new \Zimbra\Mail\Struct\TagActionSelector($retentionPolicy, TagActionOp::READ(), 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn'); $this->assertTrue($action->op()->is('read')); $this->assertSame($retentionPolicy, $action->retentionPolicy()); $action->op(TagActionOp::READ())->retentionPolicy($retentionPolicy); $this->assertTrue($action->op()->is('read')); $this->assertSame($retentionPolicy, $action->retentionPolicy()); $xml = '<?xml version="1.0"?>' . "\n" . '<action op="read" id="id" tcon="tcon" l="l" rgb="#aabbcc" tag="10" color="10" name="name" f="f" t="t" tn="tn">' . '<retentionPolicy>' . '<keep>' . '<policy type="system" id="id" name="name" lifetime="lifetime" />' . '</keep>' . '<purge>' . '<policy type="user" id="id" name="name" lifetime="lifetime" />' . '</purge>' . '</retentionPolicy>' . '</action>'; $this->assertXmlStringEqualsXmlString($xml, (string) $action); $array = array('action' => array('op' => 'read', 'id' => 'id', 'tcon' => 'tcon', 'tag' => 10, 'l' => 'l', 'rgb' => '#aabbcc', 'color' => 10, 'name' => 'name', 'f' => 'f', 't' => 't', 'tn' => 'tn', 'retentionPolicy' => array('keep' => array('policy' => array(array('type' => 'system', 'id' => 'id', 'name' => 'name', 'lifetime' => 'lifetime'))), 'purge' => array('policy' => array(array('type' => 'user', 'id' => 'id', 'name' => 'name', 'lifetime' => 'lifetime')))))); $this->assertEquals($array, $action->toArray()); }