Example #1
0
 public function testFilterTests()
 {
     $name = $this->faker->word;
     $index = mt_rand(1, 100);
     $header = $this->faker->word;
     $part = $this->faker->word;
     $comparison = $this->faker->word;
     $value = $this->faker->word;
     $where = $this->faker->word;
     $date = mt_rand(1, 10);
     $time = $this->faker->word;
     $method = $this->faker->word;
     $size = $this->faker->word;
     $folder = $this->faker->word;
     $flag = $this->faker->word;
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest($index, $header, true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest($index, $header, $part, $comparison, $value, true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest($index, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest($index, $value, true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest($index, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest($index, $header, true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest($index, $where, true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest($index, $value, true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest($index, $comparison, $time, true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest($index, $comparison, $date, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest($index, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest($index, $flag, true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest($index, $header, true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest($index, $header, $comparison, $value, true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest($index, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest($index, [$method], true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest($index, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest($index, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest($index, $header, true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest($index, $header, $comparison, $value, true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest($index, $comparison, $size, true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest($index, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest($index, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest($index, true);
     $communityRequestsTest = new \Zimbra\Mail\Struct\CommunityRequestsTest($index, true);
     $communityContentTest = new \Zimbra\Mail\Struct\CommunityContentTest($index, true);
     $communityConnectionsTest = new \Zimbra\Mail\Struct\CommunityConnectionsTest($index, true);
     $tests = [$addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest, $communityRequestsTest, $communityContentTest, $communityConnectionsTest];
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $tests);
     $this->assertTrue($filterTests->getCondition()->is('allof'));
     $this->assertSame($tests, $filterTests->getTests()->all());
     $filterTests->setCondition(FilterCondition::ALL_OF())->setTests($tests);
     $this->assertTrue($filterTests->getCondition()->is('allof'));
     $this->assertSame($tests, $filterTests->getTests()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<filterTests condition="' . FilterCondition::ALL_OF() . '">' . '<addressBookTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<addressTest index="' . $index . '" negative="true" header="' . $header . '" part="' . $part . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<attachmentTest index="' . $index . '" negative="true" />' . '<bodyTest index="' . $index . '" negative="true" value="' . $value . '" caseSensitive="true" />' . '<bulkTest index="' . $index . '" negative="true" />' . '<contactRankingTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<conversationTest index="' . $index . '" negative="true" where="' . $where . '" />' . '<currentDayOfWeekTest index="' . $index . '" negative="true" value="' . $value . '" />' . '<currentTimeTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" time="' . $time . '" />' . '<dateTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" d="' . $date . '" />' . '<facebookTest index="' . $index . '" negative="true" />' . '<flaggedTest index="' . $index . '" negative="true" flagName="' . $flag . '" />' . '<headerExistsTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<headerTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<importanceTest index="' . $index . '" negative="true" imp="' . Importance::HIGH() . '" />' . '<inviteTest index="' . $index . '" negative="true">' . '<method>' . $method . '</method>' . '</inviteTest>' . '<linkedinTest index="' . $index . '" negative="true" />' . '<listTest index="' . $index . '" negative="true" />' . '<meTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<mimeHeaderTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<sizeTest index="' . $index . '" negative="true" numberComparison="' . $comparison . '" s="' . $size . '" />' . '<socialcastTest index="' . $index . '" negative="true" />' . '<trueTest index="' . $index . '" negative="true" />' . '<twitterTest index="' . $index . '" negative="true" />' . '<communityRequestsTest index="' . $index . '" negative="true" />' . '<communityContentTest index="' . $index . '" negative="true" />' . '<communityConnectionsTest index="' . $index . '" negative="true" />' . '</filterTests>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $filterTests);
     $array = array('filterTests' => array('condition' => FilterCondition::ALL_OF()->value(), 'addressBookTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'addressTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'part' => $part, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'attachmentTest' => array('index' => $index, 'negative' => true), 'bodyTest' => array('index' => $index, 'negative' => true, 'value' => $value, 'caseSensitive' => true), 'bulkTest' => array('index' => $index, 'negative' => true), 'contactRankingTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'conversationTest' => array('index' => $index, 'negative' => true, 'where' => $where), 'currentDayOfWeekTest' => array('index' => $index, 'negative' => true, 'value' => $value), 'currentTimeTest' => array('index' => $index, 'negative' => true, 'dateComparison' => $comparison, 'time' => $time), 'dateTest' => array('index' => $index, 'negative' => true, 'dateComparison' => $comparison, 'd' => $date), 'facebookTest' => array('index' => $index, 'negative' => true), 'flaggedTest' => array('index' => $index, 'negative' => true, 'flagName' => $flag), 'headerExistsTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'headerTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'importanceTest' => array('index' => $index, 'negative' => true, 'imp' => Importance::HIGH()->value()), 'inviteTest' => array('index' => $index, 'negative' => true, 'method' => array($method)), 'linkedinTest' => array('index' => $index, 'negative' => true), 'listTest' => array('index' => $index, 'negative' => true), 'meTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'mimeHeaderTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'sizeTest' => array('index' => $index, 'negative' => true, 'numberComparison' => $comparison, 's' => $size), 'socialcastTest' => array('index' => $index, 'negative' => true), 'trueTest' => array('index' => $index, 'negative' => true), 'twitterTest' => array('index' => $index, 'negative' => true), 'communityRequestsTest' => array('index' => $index, 'negative' => true), 'communityContentTest' => array('index' => $index, 'negative' => true), 'communityConnectionsTest' => array('index' => $index, 'negative' => true)));
     $this->assertEquals($array, $filterTests->toArray());
 }
Example #2
0
 public function testFilterRules()
 {
     $name = $this->faker->word;
     $index = mt_rand(1, 100);
     $header = $this->faker->word;
     $part = $this->faker->word;
     $comparison = $this->faker->word;
     $value = $this->faker->word;
     $where = $this->faker->word;
     $date = mt_rand(1, 10);
     $time = $this->faker->word;
     $method = $this->faker->word;
     $size = $this->faker->word;
     $folder = $this->faker->word;
     $flag = $this->faker->word;
     $tag = $this->faker->word;
     $address = $this->faker->word;
     $content = $this->faker->word;
     $max = mt_rand(1, 10);
     $subject = $this->faker->word;
     $headers = $this->faker->word;
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest($index, $header, true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest($index, $header, $part, $comparison, $value, true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest($index, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest($index, $value, true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest($index, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest($index, $header, true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest($index, $where, true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest($index, $value, true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest($index, $comparison, $time, true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest($index, $comparison, $date, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest($index, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest($index, $flag, true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest($index, $header, true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest($index, $header, $comparison, $value, true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest($index, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest($index, [$method], true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest($index, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest($index, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest($index, $header, true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest($index, $header, $comparison, $value, true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest($index, $comparison, $size, true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest($index, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest($index, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest($index, true);
     $tests = [$addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest];
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $tests);
     $actionKeep = new \Zimbra\Mail\Struct\KeepAction($index);
     $actionDiscard = new \Zimbra\Mail\Struct\DiscardAction($index);
     $actionFileInto = new \Zimbra\Mail\Struct\FileIntoAction($index, $folder);
     $actionFlag = new \Zimbra\Mail\Struct\FlagAction($index, $flag);
     $actionTag = new \Zimbra\Mail\Struct\TagAction($index, $tag);
     $actionRedirect = new \Zimbra\Mail\Struct\RedirectAction($index, $address);
     $actionReply = new \Zimbra\Mail\Struct\ReplyAction($index, $content);
     $actionNotify = new \Zimbra\Mail\Struct\NotifyAction($index, $content, $address, $subject, $max, $headers);
     $actionStop = new \Zimbra\Mail\Struct\StopAction($index);
     $actions = [$actionKeep, $actionDiscard, $actionFileInto, $actionFlag, $actionTag, $actionRedirect, $actionReply, $actionNotify, $actionStop];
     $filterActions = new \Zimbra\Mail\Struct\FilterActions($actions);
     $filterRule = new \Zimbra\Mail\Struct\FilterRule($name, true, $filterTests, $filterActions);
     $filterRules = new \Zimbra\Mail\Struct\FilterRules([$filterRule]);
     $this->assertSame([$filterRule], $filterRules->getRules()->all());
     $filterRules->addRule($filterRule);
     $this->assertSame([$filterRule, $filterRule], $filterRules->getRules()->all());
     $filterRules->getRules()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<filterRules>' . '<filterRule name="' . $name . '" active="true">' . '<filterTests condition="' . FilterCondition::ALL_OF() . '">' . '<addressBookTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<addressTest index="' . $index . '" negative="true" header="' . $header . '" part="' . $part . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<attachmentTest index="' . $index . '" negative="true" />' . '<bodyTest index="' . $index . '" negative="true" value="' . $value . '" caseSensitive="true" />' . '<bulkTest index="' . $index . '" negative="true" />' . '<contactRankingTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<conversationTest index="' . $index . '" negative="true" where="' . $where . '" />' . '<currentDayOfWeekTest index="' . $index . '" negative="true" value="' . $value . '" />' . '<currentTimeTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" time="' . $time . '" />' . '<dateTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" d="' . $date . '" />' . '<facebookTest index="' . $index . '" negative="true" />' . '<flaggedTest index="' . $index . '" negative="true" flagName="' . $flag . '" />' . '<headerExistsTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<headerTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<importanceTest index="' . $index . '" negative="true" imp="' . Importance::HIGH() . '" />' . '<inviteTest index="' . $index . '" negative="true">' . '<method>' . $method . '</method>' . '</inviteTest>' . '<linkedinTest index="' . $index . '" negative="true" />' . '<listTest index="' . $index . '" negative="true" />' . '<meTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<mimeHeaderTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<sizeTest index="' . $index . '" negative="true" numberComparison="' . $comparison . '" s="' . $size . '" />' . '<socialcastTest index="' . $index . '" negative="true" />' . '<trueTest index="' . $index . '" negative="true" />' . '<twitterTest index="' . $index . '" negative="true" />' . '</filterTests>' . '<filterActions>' . '<actionKeep index="' . $index . '" />' . '<actionDiscard index="' . $index . '" />' . '<actionFileInto index="' . $index . '" folderPath="' . $folder . '" />' . '<actionFlag index="' . $index . '" flagName="' . $flag . '" />' . '<actionTag index="' . $index . '" tagName="' . $tag . '" />' . '<actionRedirect index="' . $index . '" a="' . $address . '" />' . '<actionReply index="' . $index . '">' . '<content>' . $content . '</content>' . '</actionReply>' . '<actionNotify index="' . $index . '" a="' . $address . '" su="' . $subject . '" maxBodySize="' . $max . '" origHeaders="' . $headers . '">' . '<content>' . $content . '</content>' . '</actionNotify>' . '<actionStop index="' . $index . '" />' . '</filterActions>' . '</filterRule>' . '</filterRules>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $filterRules);
     $array = array('filterRules' => array('filterRule' => array(array('name' => $name, 'active' => true, 'filterTests' => array('condition' => FilterCondition::ALL_OF()->value(), 'addressBookTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'addressTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'part' => $part, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'attachmentTest' => array('index' => $index, 'negative' => true), 'bodyTest' => array('index' => $index, 'negative' => true, 'value' => $value, 'caseSensitive' => true), 'bulkTest' => array('index' => $index, 'negative' => true), 'contactRankingTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'conversationTest' => array('index' => $index, 'negative' => true, 'where' => $where), 'currentDayOfWeekTest' => array('index' => $index, 'negative' => true, 'value' => $value), 'currentTimeTest' => array('index' => $index, 'negative' => true, 'dateComparison' => $comparison, 'time' => $time), 'dateTest' => array('index' => $index, 'negative' => true, 'dateComparison' => $comparison, 'd' => $date), 'facebookTest' => array('index' => $index, 'negative' => true), 'flaggedTest' => array('index' => $index, 'negative' => true, 'flagName' => $flag), 'headerExistsTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'headerTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'importanceTest' => array('index' => $index, 'negative' => true, 'imp' => Importance::HIGH()->value()), 'inviteTest' => array('index' => $index, 'negative' => true, 'method' => array($method)), 'linkedinTest' => array('index' => $index, 'negative' => true), 'listTest' => array('index' => $index, 'negative' => true), 'meTest' => array('index' => $index, 'negative' => true, 'header' => $header), 'mimeHeaderTest' => array('index' => $index, 'negative' => true, 'header' => $header, 'stringComparison' => $comparison, 'value' => $value, 'caseSensitive' => true), 'sizeTest' => array('index' => $index, 'negative' => true, 'numberComparison' => $comparison, 's' => $size), 'socialcastTest' => array('index' => $index, 'negative' => true), 'trueTest' => array('index' => $index, 'negative' => true), 'twitterTest' => array('index' => $index, 'negative' => true)), 'filterActions' => array('actionKeep' => array('index' => $index), 'actionDiscard' => array('index' => $index), 'actionFileInto' => array('index' => $index, 'folderPath' => $folder), 'actionFlag' => array('index' => $index, 'flagName' => $flag), 'actionTag' => array('index' => $index, 'tagName' => $tag), 'actionRedirect' => array('index' => $index, 'a' => $address), 'actionReply' => array('index' => $index, 'content' => $content), 'actionNotify' => array('index' => $index, 'content' => $content, 'a' => $address, 'su' => $subject, 'maxBodySize' => $max, 'origHeaders' => $headers), 'actionStop' => array('index' => $index))))));
     $this->assertEquals($array, $filterRules->toArray());
 }
 public function testModifyFilterRulesApi()
 {
     $name = $this->faker->word;
     $index = mt_rand(1, 100);
     $header = $this->faker->word;
     $part = $this->faker->word;
     $comparison = $this->faker->word;
     $value = $this->faker->word;
     $where = $this->faker->word;
     $date = mt_rand(1, 10);
     $time = $this->faker->word;
     $method = $this->faker->word;
     $size = $this->faker->word;
     $folder = $this->faker->word;
     $flag = $this->faker->word;
     $tag = $this->faker->word;
     $address = $this->faker->word;
     $content = $this->faker->word;
     $max = mt_rand(1, 10);
     $subject = $this->faker->word;
     $headers = $this->faker->word;
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest($index, $header, true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest($index, $header, $part, $comparison, $value, true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest($index, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest($index, $value, true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest($index, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest($index, $header, true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest($index, $where, true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest($index, $value, true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest($index, $comparison, $time, true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest($index, $comparison, $date, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest($index, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest($index, $flag, true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest($index, $header, true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest($index, $header, $comparison, $value, true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest($index, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest($index, [$method], true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest($index, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest($index, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest($index, $header, true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest($index, $header, $comparison, $value, true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest($index, $comparison, $size, true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest($index, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest($index, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest($index, true);
     $tests = [$addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest];
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $tests);
     $actionKeep = new \Zimbra\Mail\Struct\KeepAction($index);
     $actionDiscard = new \Zimbra\Mail\Struct\DiscardAction($index);
     $actionFileInto = new \Zimbra\Mail\Struct\FileIntoAction($index, $folder);
     $actionFlag = new \Zimbra\Mail\Struct\FlagAction($index, $flag);
     $actionTag = new \Zimbra\Mail\Struct\TagAction($index, $tag);
     $actionRedirect = new \Zimbra\Mail\Struct\RedirectAction($index, $address);
     $actionReply = new \Zimbra\Mail\Struct\ReplyAction($index, $content);
     $actionNotify = new \Zimbra\Mail\Struct\NotifyAction($index, $content, $address, $subject, $max, $headers);
     $actionStop = new \Zimbra\Mail\Struct\StopAction($index);
     $actions = [$actionKeep, $actionDiscard, $actionFileInto, $actionFlag, $actionTag, $actionRedirect, $actionReply, $actionNotify, $actionStop];
     $filterActions = new \Zimbra\Mail\Struct\FilterActions($actions);
     $filterRule = new \Zimbra\Mail\Struct\FilterRule($name, true, $filterTests, $filterActions);
     $filterRules = new \Zimbra\Mail\Struct\FilterRules([$filterRule]);
     $this->api->modifyFilterRules($filterRules);
     $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:ModifyFilterRulesRequest>' . '<urn1:filterRules>' . '<urn1:filterRule name="' . $name . '" active="true">' . '<urn1:filterTests condition="' . FilterCondition::ALL_OF() . '">' . '<urn1:addressBookTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<urn1:addressTest index="' . $index . '" negative="true" header="' . $header . '" part="' . $part . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<urn1:attachmentTest index="' . $index . '" negative="true" />' . '<urn1:bodyTest index="' . $index . '" negative="true" value="' . $value . '" caseSensitive="true" />' . '<urn1:bulkTest index="' . $index . '" negative="true" />' . '<urn1:contactRankingTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<urn1:conversationTest index="' . $index . '" negative="true" where="' . $where . '" />' . '<urn1:currentDayOfWeekTest index="' . $index . '" negative="true" value="' . $value . '" />' . '<urn1:currentTimeTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" time="' . $time . '" />' . '<urn1:dateTest index="' . $index . '" negative="true" dateComparison="' . $comparison . '" d="' . $date . '" />' . '<urn1:facebookTest index="' . $index . '" negative="true" />' . '<urn1:flaggedTest index="' . $index . '" negative="true" flagName="' . $flag . '" />' . '<urn1:headerExistsTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<urn1:headerTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<urn1:importanceTest index="' . $index . '" negative="true" imp="' . Importance::HIGH() . '" />' . '<urn1:inviteTest index="' . $index . '" negative="true">' . '<urn1:method>' . $method . '</urn1:method>' . '</urn1:inviteTest>' . '<urn1:linkedinTest index="' . $index . '" negative="true" />' . '<urn1:listTest index="' . $index . '" negative="true" />' . '<urn1:meTest index="' . $index . '" negative="true" header="' . $header . '" />' . '<urn1:mimeHeaderTest index="' . $index . '" negative="true" header="' . $header . '" stringComparison="' . $comparison . '" value="' . $value . '" caseSensitive="true" />' . '<urn1:sizeTest index="' . $index . '" negative="true" numberComparison="' . $comparison . '" s="' . $size . '" />' . '<urn1:socialcastTest index="' . $index . '" negative="true" />' . '<urn1:trueTest index="' . $index . '" negative="true" />' . '<urn1:twitterTest index="' . $index . '" negative="true" />' . '</urn1:filterTests>' . '<urn1:filterActions>' . '<urn1:actionKeep index="' . $index . '" />' . '<urn1:actionDiscard index="' . $index . '" />' . '<urn1:actionFileInto index="' . $index . '" folderPath="' . $folder . '" />' . '<urn1:actionFlag index="' . $index . '" flagName="' . $flag . '" />' . '<urn1:actionTag index="' . $index . '" tagName="' . $tag . '" />' . '<urn1:actionRedirect index="' . $index . '" a="' . $address . '" />' . '<urn1:actionReply index="' . $index . '">' . '<urn1:content>' . $content . '</urn1:content>' . '</urn1:actionReply>' . '<urn1:actionNotify index="' . $index . '" a="' . $address . '" su="' . $subject . '" maxBodySize="' . $max . '" origHeaders="' . $headers . '">' . '<urn1:content>' . $content . '</urn1:content>' . '</urn1:actionNotify>' . '<urn1:actionStop index="' . $index . '" />' . '</urn1:filterActions>' . '</urn1:filterRule>' . '</urn1:filterRules>' . '</urn1:ModifyFilterRulesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #4
0
 public function testFilterCondition()
 {
     $values = array('allof', 'anyof');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\FilterCondition::has($value));
     }
 }
Example #5
0
 public function testModifyOutgoingFilterRules()
 {
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest(10, 'header', true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest(10, 'header', 'part', 'stringComparison', 'value', true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest(10, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest(10, 'value', true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest(10, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest(10, 'header', true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest(10, 'where', true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest(10, 'value', true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest(10, 'dateComparison', 'time', true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest(10, 'dateComparison', 10, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest(10, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest(10, 'flagName', true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest(10, 'header', true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest(10, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest(10, array('method'), true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest(10, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest(10, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest(10, 'header', true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest(10, 'numberComparison', 's', true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest(10, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest(10, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest(10, true);
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest);
     $actionKeep = new \Zimbra\Mail\Struct\KeepAction(10);
     $actionDiscard = new \Zimbra\Mail\Struct\DiscardAction(10);
     $actionFileInto = new \Zimbra\Mail\Struct\FileIntoAction(10, 'folderPath');
     $actionFlag = new \Zimbra\Mail\Struct\FlagAction(10, 'flagName');
     $actionTag = new \Zimbra\Mail\Struct\TagAction(10, 'tagName');
     $actionRedirect = new \Zimbra\Mail\Struct\RedirectAction(10, 'a');
     $actionReply = new \Zimbra\Mail\Struct\ReplyAction(10, 'content');
     $actionNotify = new \Zimbra\Mail\Struct\NotifyAction(10, 'content', 'a', 'su', 10, 'origHeaders');
     $actionStop = new \Zimbra\Mail\Struct\StopAction(10);
     $filterActions = new \Zimbra\Mail\Struct\FilterActions($actionKeep, $actionDiscard, $actionFileInto, $actionFlag, $actionTag, $actionRedirect, $actionReply, $actionNotify, $actionStop);
     $filterRule = new \Zimbra\Mail\Struct\FilterRule('name', true, $filterTests, $filterActions);
     $filterRules = new \Zimbra\Mail\Struct\FilterRules(array($filterRule));
     $this->_api->modifyOutgoingFilterRules($filterRules);
     $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:ModifyOutgoingFilterRulesRequest>' . '<urn1:filterRules>' . '<urn1:filterRule name="name" active="true">' . '<urn1:filterTests condition="allof">' . '<urn1:addressBookTest index="10" negative="true" header="header" />' . '<urn1:addressTest index="10" negative="true" header="header" part="part" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<urn1:attachmentTest index="10" negative="true" />' . '<urn1:bodyTest index="10" negative="true" value="value" caseSensitive="true" />' . '<urn1:bulkTest index="10" negative="true" />' . '<urn1:contactRankingTest index="10" negative="true" header="header" />' . '<urn1:conversationTest index="10" negative="true" where="where" />' . '<urn1:currentDayOfWeekTest index="10" negative="true" value="value" />' . '<urn1:currentTimeTest index="10" negative="true" dateComparison="dateComparison" time="time" />' . '<urn1:dateTest index="10" negative="true" dateComparison="dateComparison" d="10" />' . '<urn1:facebookTest index="10" negative="true" />' . '<urn1:flaggedTest index="10" negative="true" flagName="flagName" />' . '<urn1:headerExistsTest index="10" negative="true" header="header" />' . '<urn1:headerTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<urn1:importanceTest index="10" negative="true" imp="high" />' . '<urn1:inviteTest index="10" negative="true">' . '<urn1:method>method</urn1:method>' . '</urn1:inviteTest>' . '<urn1:linkedinTest index="10" negative="true" />' . '<urn1:listTest index="10" negative="true" />' . '<urn1:meTest index="10" negative="true" header="header" />' . '<urn1:mimeHeaderTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<urn1:sizeTest index="10" negative="true" numberComparison="numberComparison" s="s" />' . '<urn1:socialcastTest index="10" negative="true" />' . '<urn1:trueTest index="10" negative="true" />' . '<urn1:twitterTest index="10" negative="true" />' . '</urn1:filterTests>' . '<urn1:filterActions>' . '<urn1:actionKeep index="10" />' . '<urn1:actionDiscard index="10" />' . '<urn1:actionFileInto index="10" folderPath="folderPath" />' . '<urn1:actionFlag index="10" flagName="flagName" />' . '<urn1:actionTag index="10" tagName="tagName" />' . '<urn1:actionRedirect index="10" a="a" />' . '<urn1:actionReply index="10">' . '<urn1:content>content</urn1:content>' . '</urn1:actionReply>' . '<urn1:actionNotify index="10" a="a" su="su" maxBodySize="10" origHeaders="origHeaders">' . '<urn1:content>content</urn1:content>' . '</urn1:actionNotify>' . '<urn1:actionStop index="10" />' . '</urn1:filterActions>' . '</urn1:filterRule>' . '</urn1:filterRules>' . '</urn1:ModifyOutgoingFilterRulesRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #6
0
 public function testFilterTests()
 {
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest(10, 'header', true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest(10, 'header', 'part', 'stringComparison', 'value', true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest(10, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest(10, 'value', true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest(10, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest(10, 'header', true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest(10, 'where', true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest(10, 'value', true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest(10, 'dateComparison', 'time', true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest(10, 'dateComparison', 10, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest(10, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest(10, 'flagName', true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest(10, 'header', true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest(10, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest(10, array('method'), true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest(10, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest(10, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest(10, 'header', true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest(10, 'numberComparison', 's', true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest(10, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest(10, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest(10, true);
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest);
     $this->assertTrue($filterTests->condition()->is('allof'));
     $this->assertSame($addressBookTest, $filterTests->addressBookTest());
     $this->assertSame($addressTest, $filterTests->addressTest());
     $this->assertSame($attachmentTest, $filterTests->attachmentTest());
     $this->assertSame($bodyTest, $filterTests->bodyTest());
     $this->assertSame($bulkTest, $filterTests->bulkTest());
     $this->assertSame($contactRankingTest, $filterTests->contactRankingTest());
     $this->assertSame($conversationTest, $filterTests->conversationTest());
     $this->assertSame($currentDayOfWeekTest, $filterTests->currentDayOfWeekTest());
     $this->assertSame($currentTimeTest, $filterTests->currentTimeTest());
     $this->assertSame($dateTest, $filterTests->dateTest());
     $this->assertSame($facebookTest, $filterTests->facebookTest());
     $this->assertSame($flaggedTest, $filterTests->flaggedTest());
     $this->assertSame($headerExistsTest, $filterTests->headerExistsTest());
     $this->assertSame($headerTest, $filterTests->headerTest());
     $this->assertSame($importanceTest, $filterTests->importanceTest());
     $this->assertSame($inviteTest, $filterTests->inviteTest());
     $this->assertSame($linkedinTest, $filterTests->linkedinTest());
     $this->assertSame($listTest, $filterTests->listTest());
     $this->assertSame($meTest, $filterTests->meTest());
     $this->assertSame($mimeHeaderTest, $filterTests->mimeHeaderTest());
     $this->assertSame($sizeTest, $filterTests->sizeTest());
     $this->assertSame($socialcastTest, $filterTests->socialcastTest());
     $this->assertSame($trueTest, $filterTests->trueTest());
     $this->assertSame($twitterTest, $filterTests->twitterTest());
     $filterTests->condition(FilterCondition::ALL_OF())->addressBookTest($addressBookTest)->addressTest($addressTest)->attachmentTest($attachmentTest)->bodyTest($bodyTest)->bulkTest($bulkTest)->contactRankingTest($contactRankingTest)->conversationTest($conversationTest)->currentDayOfWeekTest($currentDayOfWeekTest)->currentTimeTest($currentTimeTest)->dateTest($dateTest)->facebookTest($facebookTest)->flaggedTest($flaggedTest)->headerExistsTest($headerExistsTest)->headerTest($headerTest)->importanceTest($importanceTest)->inviteTest($inviteTest)->linkedinTest($linkedinTest)->listTest($listTest)->meTest($meTest)->mimeHeaderTest($mimeHeaderTest)->sizeTest($sizeTest)->socialcastTest($socialcastTest)->trueTest($trueTest)->twitterTest($twitterTest);
     $this->assertTrue($filterTests->condition()->is('allof'));
     $this->assertSame($addressBookTest, $filterTests->addressBookTest());
     $this->assertSame($addressTest, $filterTests->addressTest());
     $this->assertSame($attachmentTest, $filterTests->attachmentTest());
     $this->assertSame($bodyTest, $filterTests->bodyTest());
     $this->assertSame($bulkTest, $filterTests->bulkTest());
     $this->assertSame($contactRankingTest, $filterTests->contactRankingTest());
     $this->assertSame($conversationTest, $filterTests->conversationTest());
     $this->assertSame($currentDayOfWeekTest, $filterTests->currentDayOfWeekTest());
     $this->assertSame($currentTimeTest, $filterTests->currentTimeTest());
     $this->assertSame($dateTest, $filterTests->dateTest());
     $this->assertSame($facebookTest, $filterTests->facebookTest());
     $this->assertSame($flaggedTest, $filterTests->flaggedTest());
     $this->assertSame($headerExistsTest, $filterTests->headerExistsTest());
     $this->assertSame($headerTest, $filterTests->headerTest());
     $this->assertSame($importanceTest, $filterTests->importanceTest());
     $this->assertSame($inviteTest, $filterTests->inviteTest());
     $this->assertSame($linkedinTest, $filterTests->linkedinTest());
     $this->assertSame($listTest, $filterTests->listTest());
     $this->assertSame($meTest, $filterTests->meTest());
     $this->assertSame($mimeHeaderTest, $filterTests->mimeHeaderTest());
     $this->assertSame($sizeTest, $filterTests->sizeTest());
     $this->assertSame($socialcastTest, $filterTests->socialcastTest());
     $this->assertSame($trueTest, $filterTests->trueTest());
     $this->assertSame($twitterTest, $filterTests->twitterTest());
     $xml = '<?xml version="1.0"?>' . "\n" . '<filterTests condition="allof">' . '<addressBookTest index="10" negative="true" header="header" />' . '<addressTest index="10" negative="true" header="header" part="part" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<attachmentTest index="10" negative="true" />' . '<bodyTest index="10" negative="true" value="value" caseSensitive="true" />' . '<bulkTest index="10" negative="true" />' . '<contactRankingTest index="10" negative="true" header="header" />' . '<conversationTest index="10" negative="true" where="where" />' . '<currentDayOfWeekTest index="10" negative="true" value="value" />' . '<currentTimeTest index="10" negative="true" dateComparison="dateComparison" time="time" />' . '<dateTest index="10" negative="true" dateComparison="dateComparison" d="10" />' . '<facebookTest index="10" negative="true" />' . '<flaggedTest index="10" negative="true" flagName="flagName" />' . '<headerExistsTest index="10" negative="true" header="header" />' . '<headerTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<importanceTest index="10" negative="true" imp="high" />' . '<inviteTest index="10" negative="true">' . '<method>method</method>' . '</inviteTest>' . '<linkedinTest index="10" negative="true" />' . '<listTest index="10" negative="true" />' . '<meTest index="10" negative="true" header="header" />' . '<mimeHeaderTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<sizeTest index="10" negative="true" numberComparison="numberComparison" s="s" />' . '<socialcastTest index="10" negative="true" />' . '<trueTest index="10" negative="true" />' . '<twitterTest index="10" negative="true" />' . '</filterTests>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $filterTests);
     $array = array('filterTests' => array('condition' => 'allof', 'addressBookTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'addressTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'part' => 'part', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'attachmentTest' => array('index' => 10, 'negative' => true), 'bodyTest' => array('index' => 10, 'negative' => true, 'value' => 'value', 'caseSensitive' => true), 'bulkTest' => array('index' => 10, 'negative' => true), 'contactRankingTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'conversationTest' => array('index' => 10, 'negative' => true, 'where' => 'where'), 'currentDayOfWeekTest' => array('index' => 10, 'negative' => true, 'value' => 'value'), 'currentTimeTest' => array('index' => 10, 'negative' => true, 'dateComparison' => 'dateComparison', 'time' => 'time'), 'dateTest' => array('index' => 10, 'negative' => true, 'dateComparison' => 'dateComparison', 'd' => 10), 'facebookTest' => array('index' => 10, 'negative' => true), 'flaggedTest' => array('index' => 10, 'negative' => true, 'flagName' => 'flagName'), 'headerExistsTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'headerTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'importanceTest' => array('index' => 10, 'negative' => true, 'imp' => 'high'), 'inviteTest' => array('index' => 10, 'negative' => true, 'method' => array('method')), 'linkedinTest' => array('index' => 10, 'negative' => true), 'listTest' => array('index' => 10, 'negative' => true), 'meTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'mimeHeaderTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'sizeTest' => array('index' => 10, 'negative' => true, 'numberComparison' => 'numberComparison', 's' => 's'), 'socialcastTest' => array('index' => 10, 'negative' => true), 'trueTest' => array('index' => 10, 'negative' => true), 'twitterTest' => array('index' => 10, 'negative' => true)));
     $this->assertEquals($array, $filterTests->toArray());
 }
Example #7
0
 public function testModifyOutgoingFilterRules()
 {
     $addressBookTest = new \Zimbra\Mail\Struct\AddressBookTest(10, 'header', true);
     $addressTest = new \Zimbra\Mail\Struct\AddressTest(10, 'header', 'part', 'stringComparison', 'value', true, true);
     $attachmentTest = new \Zimbra\Mail\Struct\AttachmentTest(10, true);
     $bodyTest = new \Zimbra\Mail\Struct\BodyTest(10, 'value', true, true);
     $bulkTest = new \Zimbra\Mail\Struct\BulkTest(10, true);
     $contactRankingTest = new \Zimbra\Mail\Struct\ContactRankingTest(10, 'header', true);
     $conversationTest = new \Zimbra\Mail\Struct\ConversationTest(10, 'where', true);
     $currentDayOfWeekTest = new \Zimbra\Mail\Struct\CurrentDayOfWeekTest(10, 'value', true);
     $currentTimeTest = new \Zimbra\Mail\Struct\CurrentTimeTest(10, 'dateComparison', 'time', true);
     $dateTest = new \Zimbra\Mail\Struct\DateTest(10, 'dateComparison', 10, true);
     $facebookTest = new \Zimbra\Mail\Struct\FacebookTest(10, true);
     $flaggedTest = new \Zimbra\Mail\Struct\FlaggedTest(10, 'flagName', true);
     $headerExistsTest = new \Zimbra\Mail\Struct\HeaderExistsTest(10, 'header', true);
     $headerTest = new \Zimbra\Mail\Struct\HeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $importanceTest = new \Zimbra\Mail\Struct\ImportanceTest(10, Importance::HIGH(), true);
     $inviteTest = new \Zimbra\Mail\Struct\InviteTest(10, array('method'), true);
     $linkedinTest = new \Zimbra\Mail\Struct\LinkedInTest(10, true);
     $listTest = new \Zimbra\Mail\Struct\ListTest(10, true);
     $meTest = new \Zimbra\Mail\Struct\MeTest(10, 'header', true);
     $mimeHeaderTest = new \Zimbra\Mail\Struct\MimeHeaderTest(10, 'header', 'stringComparison', 'value', true, true);
     $sizeTest = new \Zimbra\Mail\Struct\SizeTest(10, 'numberComparison', 's', true);
     $socialcastTest = new \Zimbra\Mail\Struct\SocialcastTest(10, true);
     $trueTest = new \Zimbra\Mail\Struct\TrueTest(10, true);
     $twitterTest = new \Zimbra\Mail\Struct\TwitterTest(10, true);
     $filterTests = new \Zimbra\Mail\Struct\FilterTests(FilterCondition::ALL_OF(), $addressBookTest, $addressTest, $attachmentTest, $bodyTest, $bulkTest, $contactRankingTest, $conversationTest, $currentDayOfWeekTest, $currentTimeTest, $dateTest, $facebookTest, $flaggedTest, $headerExistsTest, $headerTest, $importanceTest, $inviteTest, $linkedinTest, $listTest, $meTest, $mimeHeaderTest, $sizeTest, $socialcastTest, $trueTest, $twitterTest);
     $actionKeep = new \Zimbra\Mail\Struct\KeepAction(10);
     $actionDiscard = new \Zimbra\Mail\Struct\DiscardAction(10);
     $actionFileInto = new \Zimbra\Mail\Struct\FileIntoAction(10, 'folderPath');
     $actionFlag = new \Zimbra\Mail\Struct\FlagAction(10, 'flagName');
     $actionTag = new \Zimbra\Mail\Struct\TagAction(10, 'tagName');
     $actionRedirect = new \Zimbra\Mail\Struct\RedirectAction(10, 'a');
     $actionReply = new \Zimbra\Mail\Struct\ReplyAction(10, 'content');
     $actionNotify = new \Zimbra\Mail\Struct\NotifyAction(10, 'content', 'a', 'su', 10, 'origHeaders');
     $actionStop = new \Zimbra\Mail\Struct\StopAction(10);
     $filterActions = new \Zimbra\Mail\Struct\FilterActions($actionKeep, $actionDiscard, $actionFileInto, $actionFlag, $actionTag, $actionRedirect, $actionReply, $actionNotify, $actionStop);
     $filterRule = new \Zimbra\Mail\Struct\FilterRule('name', true, $filterTests, $filterActions);
     $filterRules = new \Zimbra\Mail\Struct\FilterRules(array($filterRule));
     $req = new \Zimbra\Mail\Request\ModifyOutgoingFilterRules($filterRules);
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame($filterRules, $req->filterRules());
     $req->filterRules($filterRules);
     $this->assertSame($filterRules, $req->filterRules());
     $xml = '<?xml version="1.0"?>' . "\n" . '<ModifyOutgoingFilterRulesRequest>' . '<filterRules>' . '<filterRule name="name" active="true">' . '<filterTests condition="allof">' . '<addressBookTest index="10" negative="true" header="header" />' . '<addressTest index="10" negative="true" header="header" part="part" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<attachmentTest index="10" negative="true" />' . '<bodyTest index="10" negative="true" value="value" caseSensitive="true" />' . '<bulkTest index="10" negative="true" />' . '<contactRankingTest index="10" negative="true" header="header" />' . '<conversationTest index="10" negative="true" where="where" />' . '<currentDayOfWeekTest index="10" negative="true" value="value" />' . '<currentTimeTest index="10" negative="true" dateComparison="dateComparison" time="time" />' . '<dateTest index="10" negative="true" dateComparison="dateComparison" d="10" />' . '<facebookTest index="10" negative="true" />' . '<flaggedTest index="10" negative="true" flagName="flagName" />' . '<headerExistsTest index="10" negative="true" header="header" />' . '<headerTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<importanceTest index="10" negative="true" imp="high" />' . '<inviteTest index="10" negative="true">' . '<method>method</method>' . '</inviteTest>' . '<linkedinTest index="10" negative="true" />' . '<listTest index="10" negative="true" />' . '<meTest index="10" negative="true" header="header" />' . '<mimeHeaderTest index="10" negative="true" header="header" stringComparison="stringComparison" value="value" caseSensitive="true" />' . '<sizeTest index="10" negative="true" numberComparison="numberComparison" s="s" />' . '<socialcastTest index="10" negative="true" />' . '<trueTest index="10" negative="true" />' . '<twitterTest index="10" negative="true" />' . '</filterTests>' . '<filterActions>' . '<actionKeep index="10" />' . '<actionDiscard index="10" />' . '<actionFileInto index="10" folderPath="folderPath" />' . '<actionFlag index="10" flagName="flagName" />' . '<actionTag index="10" tagName="tagName" />' . '<actionRedirect index="10" a="a" />' . '<actionReply index="10">' . '<content>content</content>' . '</actionReply>' . '<actionNotify index="10" a="a" su="su" maxBodySize="10" origHeaders="origHeaders">' . '<content>content</content>' . '</actionNotify>' . '<actionStop index="10" />' . '</filterActions>' . '</filterRule>' . '</filterRules>' . '</ModifyOutgoingFilterRulesRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('ModifyOutgoingFilterRulesRequest' => array('_jsns' => 'urn:zimbraMail', 'filterRules' => array('filterRule' => array(array('name' => 'name', 'active' => true, 'filterTests' => array('condition' => 'allof', 'addressBookTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'addressTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'part' => 'part', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'attachmentTest' => array('index' => 10, 'negative' => true), 'bodyTest' => array('index' => 10, 'negative' => true, 'value' => 'value', 'caseSensitive' => true), 'bulkTest' => array('index' => 10, 'negative' => true), 'contactRankingTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'conversationTest' => array('index' => 10, 'negative' => true, 'where' => 'where'), 'currentDayOfWeekTest' => array('index' => 10, 'negative' => true, 'value' => 'value'), 'currentTimeTest' => array('index' => 10, 'negative' => true, 'dateComparison' => 'dateComparison', 'time' => 'time'), 'dateTest' => array('index' => 10, 'negative' => true, 'dateComparison' => 'dateComparison', 'd' => 10), 'facebookTest' => array('index' => 10, 'negative' => true), 'flaggedTest' => array('index' => 10, 'negative' => true, 'flagName' => 'flagName'), 'headerExistsTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'headerTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'importanceTest' => array('index' => 10, 'negative' => true, 'imp' => 'high'), 'inviteTest' => array('index' => 10, 'negative' => true, 'method' => array('method')), 'linkedinTest' => array('index' => 10, 'negative' => true), 'listTest' => array('index' => 10, 'negative' => true), 'meTest' => array('index' => 10, 'negative' => true, 'header' => 'header'), 'mimeHeaderTest' => array('index' => 10, 'negative' => true, 'header' => 'header', 'stringComparison' => 'stringComparison', 'value' => 'value', 'caseSensitive' => true), 'sizeTest' => array('index' => 10, 'negative' => true, 'numberComparison' => 'numberComparison', 's' => 's'), 'socialcastTest' => array('index' => 10, 'negative' => true), 'trueTest' => array('index' => 10, 'negative' => true), 'twitterTest' => array('index' => 10, 'negative' => true)), 'filterActions' => array('actionKeep' => array('index' => 10), 'actionDiscard' => array('index' => 10), 'actionFileInto' => array('index' => 10, 'folderPath' => 'folderPath'), 'actionFlag' => array('index' => 10, 'flagName' => 'flagName'), 'actionTag' => array('index' => 10, 'tagName' => 'tagName'), 'actionRedirect' => array('index' => 10, 'a' => 'a'), 'actionReply' => array('index' => 10, 'content' => 'content'), 'actionNotify' => array('index' => 10, 'content' => 'content', 'a' => 'a', 'su' => 'su', 'maxBodySize' => 10, 'origHeaders' => 'origHeaders'), 'actionStop' => array('index' => 10)))))));
     $this->assertEquals($array, $req->toArray());
 }