public function testContactActionSelector()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $aid = $this->faker->uuid;
     $attr_id = mt_rand(0, 10);
     $part = $this->faker->word;
     $attr = new NewContactAttr($name, $value, $aid, $attr_id, $part);
     $id = $this->faker->word;
     $tcon = $this->faker->word;
     $tag = mt_rand(0, 10);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(0, 128);
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $action = new ContactActionSelector(ContactActionOp::MOVE(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames, [$attr]);
     $this->assertInstanceOf('\\Zimbra\\Mail\\Struct\\ActionSelector', $action);
     $this->assertTrue($action->getOperation()->is('move'));
     $this->assertSame([$attr], $action->getAttrs()->all());
     $action->setOperation(ContactActionOp::MOVE())->addAttr($attr);
     $this->assertTrue($action->getOperation()->is('move'));
     $this->assertSame([$attr, $attr], $action->getAttrs()->all());
     $action->getAttrs()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . ContactActionOp::MOVE() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '">' . '<a n="' . $name . '" aid="' . $aid . '" id="' . $attr_id . '" part="' . $part . '">' . $value . '</a>' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => ContactActionOp::MOVE()->value(), 'id' => $id, 'tcon' => $tcon, 'tag' => $tag, 'l' => $folder, 'rgb' => $rgb, 'color' => $color, 'name' => $name, 'f' => $flags, 't' => $tags, 'tn' => $tagNames, 'a' => array(array('n' => $name, '_content' => $value, 'aid' => $aid, 'id' => $attr_id, 'part' => $part))));
     $this->assertEquals($array, $action->toArray());
 }
Esempio n. 2
0
 public function testActionSelector()
 {
     $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 \Zimbra\Mail\Struct\ActionSelector(ContactActionOp::MOVE(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames);
     $this->assertSame($id, $action->getIds());
     $this->assertSame($tcon, $action->getConstraint());
     $this->assertSame($tag, $action->getTag());
     $this->assertSame($folder, $action->getFolder());
     $this->assertSame($rgb, $action->getRgb());
     $this->assertSame($color, $action->getColor());
     $this->assertSame($name, $action->getName());
     $this->assertSame($flags, $action->getFlags());
     $this->assertSame($tags, $action->getTags());
     $this->assertSame($tagNames, $action->getTagNames());
     $action->setIds($id)->setConstraint($tcon)->setTag($tag)->setFolder($folder)->setRgb($rgb)->setColor($color)->setName($name)->setFlags($flags)->setTags($tags)->setTagNames($tagNames);
     $this->assertSame($id, $action->getIds());
     $this->assertSame($tcon, $action->getConstraint());
     $this->assertSame($tag, $action->getTag());
     $this->assertSame($folder, $action->getFolder());
     $this->assertSame($rgb, $action->getRgb());
     $this->assertSame($color, $action->getColor());
     $this->assertSame($name, $action->getName());
     $this->assertSame($flags, $action->getFlags());
     $this->assertSame($tags, $action->getTags());
     $this->assertSame($tagNames, $action->getTagNames());
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . ContactActionOp::MOVE() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => ContactActionOp::MOVE()->value(), 'id' => $id, 'tcon' => $tcon, 'tag' => $tag, 'l' => $folder, 'rgb' => $rgb, 'color' => $color, 'name' => $name, 'f' => $flags, 't' => $tags, 'tn' => $tagNames));
     $this->assertEquals($array, $action->toArray());
 }
Esempio n. 3
0
 public function testContactActionApi()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $aid = $this->faker->uuid;
     $attr_id = mt_rand(0, 10);
     $part = $this->faker->word;
     $attr = new NewContactAttr($name, $value, $aid, $attr_id, $part);
     $id = $this->faker->word;
     $tcon = $this->faker->word;
     $tag = mt_rand(0, 10);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(0, 127);
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $action = new ContactActionSelector(ContactActionOp::MOVE(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames, [$attr]);
     $this->api->contactAction($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:ContactActionRequest>' . '<urn1:action op="' . ContactActionOp::MOVE() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '">' . '<urn1:a n="' . $name . '" aid="' . $aid . '" id="' . $attr_id . '" part="' . $part . '">' . $value . '</urn1:a>' . '</urn1:action>' . '</urn1:ContactActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 4
0
 public function testContactActionOp()
 {
     $values = array('move', 'delete', 'flag', 'trash', 'tag', 'update');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\ContactActionOp::has($value));
     }
 }
Esempio n. 5
0
 public function testContactAction()
 {
     $a = new \Zimbra\Mail\Struct\NewContactAttr('n', 'value', 'aid', 10, 'part');
     $action = new \Zimbra\Mail\Struct\ContactActionSelector(ContactActionOp::MOVE(), 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn', array($a));
     $this->_api->contactAction($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:ContactActionRequest>' . '<urn1:action op="move" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn">' . '<urn1:a n="n" aid="aid" id="10" part="part">value</urn1:a>' . '</urn1:action>' . '</urn1:ContactActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 6
0
 public function testContactActionSelector()
 {
     $a = new \Zimbra\Mail\Struct\NewContactAttr('n', 'value', 'aid', 10, 'part');
     $action = new \Zimbra\Mail\Struct\ContactActionSelector(ContactActionOp::MOVE(), 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn', array($a));
     $this->assertInstanceOf('\\Zimbra\\Mail\\Struct\\ActionSelector', $action);
     $this->assertTrue($action->op()->is('move'));
     $this->assertSame(array($a), $action->a()->all());
     $action->op(ContactActionOp::MOVE())->addA($a);
     $this->assertTrue($action->op()->is('move'));
     $this->assertSame(array($a, $a), $action->a()->all());
     $action->a()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="move" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn">' . '<a n="n" aid="aid" id="10" part="part">value</a>' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => 'move', 'id' => 'id', 'tcon' => 'tcon', 'tag' => 10, 'l' => 'l', 'rgb' => '#aabbcc', 'color' => 10, 'name' => 'name', 'f' => 'f', 't' => 't', 'tn' => 'tn', 'a' => array(array('n' => 'n', '_content' => 'value', 'aid' => 'aid', 'id' => 10, 'part' => 'part'))));
     $this->assertEquals($array, $action->toArray());
 }
Esempio n. 7
0
 public function testContactAction()
 {
     $a = new \Zimbra\Mail\Struct\NewContactAttr('n', 'value', 'aid', 10, 'part');
     $action = new \Zimbra\Mail\Struct\ContactActionSelector(ContactActionOp::MOVE(), 'id', 'tcon', 10, 'l', '#aabbcc', 10, 'name', 'f', 't', 'tn', array($a));
     $req = new \Zimbra\Mail\Request\ContactAction($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" . '<ContactActionRequest>' . '<action op="move" id="id" tcon="tcon" tag="10" l="l" rgb="#aabbcc" color="10" name="name" f="f" t="t" tn="tn">' . '<a n="n" aid="aid" id="10" part="part">value</a>' . '</action>' . '</ContactActionRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('ContactActionRequest' => array('_jsns' => 'urn:zimbraMail', 'action' => array('op' => 'move', 'id' => 'id', 'tcon' => 'tcon', 'tag' => 10, 'l' => 'l', 'rgb' => '#aabbcc', 'color' => 10, 'name' => 'name', 'f' => 'f', 't' => 't', 'tn' => 'tn', 'a' => array(array('n' => 'n', '_content' => 'value', 'aid' => 'aid', 'id' => 10, 'part' => 'part')))));
     $this->assertEquals($array, $req->toArray());
 }