public function testDistributionListSubscribeReq() { $value = $this->faker->word; $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::UNSUBSCRIBE(), $value, false); $this->assertTrue($subsReq->getOp()->is('unsubscribe')); $this->assertSame($value, $subsReq->getValue()); $this->assertFalse($subsReq->getBccOwners()); $subsReq->setOp(DLSubscribeOp::SUBSCRIBE())->setBccOwners(true); $this->assertTrue($subsReq->getOp()->is('subscribe')); $this->assertTrue($subsReq->getBccOwners()); $xml = '<?xml version="1.0"?>' . "\n" . '<subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</subsReq>'; $this->assertXmlStringEqualsXmlString($xml, (string) $subsReq); $array = ['subsReq' => ['op' => DLSubscribeOp::SUBSCRIBE()->value(), '_content' => $value, 'bccOwners' => true]]; $this->assertEquals($array, $subsReq->toArray()); }
public function testSubscribeDistributionListRequest() { $value = $this->faker->word; $dl = new DistributionListSelector(DLBy::NAME(), $value); $req = new SubscribeDistributionList(DLSubscribeOp::UNSUBSCRIBE(), $dl); $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req); $this->assertSame('unsubscribe', $req->getOp()->value()); $this->assertSame($dl, $req->getDl()); $req->setOp(DLSubscribeOp::SUBSCRIBE())->setDl($dl); $this->assertSame('subscribe', $req->getOp()->value()); $this->assertSame($dl, $req->getDl()); $xml = '<?xml version="1.0"?>' . "\n" . '<SubscribeDistributionListRequest op="' . DLSubscribeOp::SUBSCRIBE() . '">' . '<dl by="' . DLBy::NAME() . '">' . $value . '</dl>' . '</SubscribeDistributionListRequest>'; $this->assertXmlStringEqualsXmlString($xml, (string) $req); $array = ['SubscribeDistributionListRequest' => ['_jsns' => 'urn:zimbraAccount', 'op' => DLSubscribeOp::SUBSCRIBE()->value(), 'dl' => ['by' => DLBy::NAME()->value(), '_content' => $value]]]; $this->assertEquals($array, $req->toArray()); }