示例#1
0
 public function testModifyContactSpec()
 {
     $id = mt_rand(1, 10);
     $name = $this->faker->word;
     $value = $this->faker->word;
     $aid = $this->faker->uuid;
     $part = $this->faker->word;
     $op = $this->faker->randomElement(['+', '-', 'reset']);
     $tn = $this->faker->word;
     $a = new ModifyContactAttr($name, $value, $aid, $id, $part, $op);
     $m = new ModifyContactGroupMember(MemberType::CONTACT(), $value, $op);
     $cn = new ModifyContactSpec($id, $tn, [$a], [$m]);
     $this->assertSame(array($a), $cn->getAttrs()->all());
     $this->assertSame(array($m), $cn->getMembers()->all());
     $this->assertSame($id, $cn->getId());
     $this->assertSame($tn, $cn->getTagNames());
     $cn->addAttr($a)->addMember($m)->setId($id)->setTagNames($tn);
     $this->assertSame(array($a, $a), $cn->getAttrs()->all());
     $this->assertSame(array($m, $m), $cn->getMembers()->all());
     $this->assertSame($id, $cn->getId());
     $this->assertSame($tn, $cn->getTagNames());
     $cn = new ModifyContactSpec($id, $tn, [$a], [$m]);
     $xml = '<?xml version="1.0"?>' . "\n" . '<cn id="' . $id . '" tn="' . $tn . '">' . '<a n="' . $name . '" aid="' . $aid . '" id="' . $id . '" part="' . $part . '" op="' . $op . '">' . $value . '</a>' . '<m type="' . MemberType::CONTACT() . '" value="' . $value . '" op="' . $op . '" />' . '</cn>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $cn);
     $array = array('cn' => array('id' => $id, 'tn' => $tn, 'a' => array(array('n' => $name, '_content' => $value, 'aid' => $aid, 'id' => $id, 'part' => $part, 'op' => $op)), 'm' => array(array('type' => MemberType::CONTACT()->value(), 'value' => $value, 'op' => $op))));
     $this->assertEquals($array, $cn->toArray());
 }
 public function testModifyContactGroupMember()
 {
     $value = $this->faker->word;
     $op = $this->faker->randomElement(['+', '-', 'reset']);
     $m = new ModifyContactGroupMember(MemberType::CONTACT(), $value, $op);
     $this->assertSame('C', $m->getType()->value());
     $this->assertSame($value, $m->getValue());
     $this->assertSame($op, $m->getOperation());
     $m->setType(MemberType::CONTACT())->setValue($value)->setOperation($op);
     $this->assertSame('C', $m->getType()->value());
     $this->assertSame($value, $m->getValue());
     $this->assertSame($op, $m->getOperation());
     $xml = '<?xml version="1.0"?>' . "\n" . '<m type="' . MemberType::CONTACT() . '" value="' . $value . '" op="' . $op . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $m);
     $array = array('m' => array('type' => MemberType::CONTACT()->value(), 'value' => $value, 'op' => $op));
     $this->assertEquals($array, $m->toArray());
 }
示例#3
0
 public function testModifyContactApi()
 {
     $id = mt_rand(1, 10);
     $name = $this->faker->word;
     $value = $this->faker->word;
     $aid = $this->faker->uuid;
     $part = $this->faker->word;
     $op = $this->faker->randomElement(['+', '-', 'reset']);
     $tn = $this->faker->word;
     $a = new ModifyContactAttr($name, $value, $aid, $id, $part, $op);
     $m = new ModifyContactGroupMember(MemberType::CONTACT(), $value, $op);
     $cn = new ModifyContactSpec($id, $tn, [$a], [$m]);
     $this->api->modifyContact($cn, true, true);
     $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:ModifyContactRequest replace="true" verbose="true">' . '<urn1:cn id="' . $id . '" tn="' . $tn . '">' . '<urn1:a n="' . $name . '" aid="' . $aid . '" id="' . $id . '" part="' . $part . '" op="' . $op . '">' . $value . '</urn1:a>' . '<urn1:m type="' . MemberType::CONTACT() . '" value="' . $value . '" op="' . $op . '" />' . '</urn1:cn>' . '</urn1:ModifyContactRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }