public function testSignatureContent()
 {
     $value = $this->faker->word;
     $content = new SignatureContent($value, ContentType::TEXT_PLAIN());
     $this->assertSame($value, $content->getValue());
     $this->assertSame('text/plain', $content->getContentType()->value());
     $content->setContentType(ContentType::TEXT_HTML());
     $this->assertSame('text/html', $content->getContentType()->value());
     $xml = '<?xml version="1.0"?>' . "\n" . '<content type="' . ContentType::TEXT_HTML() . '">' . $value . '</content>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $content);
     $array = ['content' => ['type' => ContentType::TEXT_HTML()->value(), '_content' => $value]];
     $this->assertEquals($array, $content->toArray());
 }
Esempio n. 2
0
 public function testModifySignatureApi()
 {
     $value = $this->faker->word;
     $name = $this->faker->word;
     $id = $this->faker->word;
     $cid = $this->faker->word;
     $content = new SignatureContent($value, ContentType::TEXT_HTML());
     $signature = new Signature($name, $id, $cid, [$content]);
     $this->api->modifySignature($signature);
     $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:zimbraAccount">' . '<env:Body>' . '<urn1:ModifySignatureRequest>' . '<urn1:signature name="' . $name . '" id="' . $id . '">' . '<urn1:cid>' . $cid . '</urn1:cid>' . '<urn1:content type="' . ContentType::TEXT_HTML() . '">' . $value . '</urn1:content>' . '</urn1:signature>' . '</urn1:ModifySignatureRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 3
0
 public function testContentType()
 {
     $values = array('text/plain', 'text/html');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\ContentType::has($value));
     }
 }
Esempio n. 4
0
 public function testModifySignature()
 {
     $value = md5(self::randomString());
     $name = self::randomName();
     $id = self::randomName();
     $cid = self::randomName();
     $content = new \Zimbra\Account\Struct\SignatureContent($value, ContentType::TEXT_HTML());
     $signature = new \Zimbra\Account\Struct\Signature($name, $id, $cid, array($content));
     $this->_api->modifySignature($signature);
     $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:zimbraAccount">' . '<env:Body>' . '<urn1:ModifySignatureRequest>' . '<urn1:signature name="' . $name . '" id="' . $id . '">' . '<urn1:cid>' . $cid . '</urn1:cid>' . '<urn1:content type="' . ContentType::TEXT_HTML() . '">' . $value . '</urn1:content>' . '</urn1:signature>' . '</urn1:ModifySignatureRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 5
0
 public function testModifySignature()
 {
     $value = md5(self::randomString());
     $name = self::randomName();
     $id = self::randomName();
     $cid = self::randomName();
     $content = new \Zimbra\Account\Struct\SignatureContent($value, ContentType::TEXT_HTML());
     $signature = new \Zimbra\Account\Struct\Signature($name, $id, $cid, [$content]);
     $req = new \Zimbra\Account\Request\ModifySignature($signature);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame($signature, $req->getSignature());
     $req->setSignature($signature);
     $this->assertSame($signature, $req->getSignature());
     $xml = '<?xml version="1.0"?>' . "\n" . '<ModifySignatureRequest>' . '<signature name="' . $name . '" id="' . $id . '">' . '<cid>' . $cid . '</cid>' . '<content type="' . ContentType::TEXT_HTML() . '">' . $value . '</content>' . '</signature>' . '</ModifySignatureRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['ModifySignatureRequest' => ['_jsns' => 'urn:zimbraAccount', 'signature' => ['name' => $name, 'id' => $id, 'cid' => $cid, 'content' => [['type' => ContentType::TEXT_HTML()->value(), '_content' => $value]]]]];
     $this->assertEquals($array, $req->toArray());
 }
Esempio n. 6
0
 public function testSignature()
 {
     $value = md5(self::randomString());
     $name = self::randomName();
     $id = self::randomName();
     $cid = self::randomName();
     $content1 = new \Zimbra\Account\Struct\SignatureContent($value, ContentType::TEXT_PLAIN());
     $content2 = new \Zimbra\Account\Struct\SignatureContent($value, ContentType::TEXT_HTML());
     $sig = new \Zimbra\Account\Struct\Signature($name, $id, $cid, [$content1]);
     $this->assertSame($name, $sig->getName());
     $this->assertSame($id, $sig->getId());
     $this->assertSame($cid, $sig->getCid());
     $this->assertSame([$content1], $sig->getContents()->all());
     $sig->setName($name)->setId($id)->setCid($cid)->addContent($content2);
     $this->assertSame($name, $sig->getName());
     $this->assertSame($id, $sig->getId());
     $this->assertSame($cid, $sig->getCid());
     $this->assertSame([$content1, $content2], $sig->getContents()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<signature name="' . $name . '" id="' . $id . '">' . '<cid>' . $cid . '</cid>' . '<content type="' . ContentType::TEXT_PLAIN() . '">' . $value . '</content>' . '<content type="' . ContentType::TEXT_HTML() . '">' . $value . '</content>' . '</signature>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $sig);
     $array = ['signature' => ['name' => $name, 'id' => $id, 'cid' => $cid, 'content' => [['type' => ContentType::TEXT_PLAIN()->value(), '_content' => $value], ['type' => ContentType::TEXT_HTML()->value(), '_content' => $value]]]];
     $this->assertEquals($array, $sig->toArray());
 }