Browse files

added test for setDigest/setOption

  • Loading branch information...
1 parent 85ce544 commit 7a87e1645913848316df5afa369463d3a8d540d7 @hm2k hm2k committed Jan 30, 2012
Showing with 386 additions and 0 deletions.
  1. +9 −0 tests/setdigest-fail.html
  2. +326 −0 tests/setdigest-success.html
  3. +51 −0 tests/test_setdigest.phpt
View
9 tests/setdigest-fail.html
@@ -0,0 +1,9 @@
+
+<head><title>Bug in Mailman version 2.1.14-1</title></head>
+<body bgcolor=#ffffff><h2>Bug in Mailman version 2.1.14-1</h2>
+<p><h3>We're sorry, we hit a bug!</h3>
+
+<p>Please inform the webmaster for this site of this
+problem. Printing of traceback and other system information has been
+explicitly inhibited, but the webmaster can find this information in the
+Mailman error logs.
View
326 tests/setdigest-success.html
@@ -0,0 +1,326 @@
+
+<html>
+<head>
+ <link rel="SHORTCUT ICON" href="/img-sys/mm-icon.png">
+ <title>john.smith at example.co.uk membership configuration for Test
+ </title>
+</head>
+<BODY BGCOLOR="#ffffff">
+ <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
+ <TR><TD WIDTH="100%" BGCOLOR="#99CCFF"><B>
+ <FONT COLOR="#000000" SIZE=+1>
+ Test mailing list membership configuration for
+ john.smith at example.co.uk
+ </FONT></B></TD></TR>
+ </TABLE>
+<p>
+<table width="100%" border="0" cellspacing="5" cellpadding="5">
+ <tr><td>
+ <b>john.smith at example.co.uk</b>'s subscription status,
+ password, and options for the Test mailing list.
+ </td><td><FORM Method=POST ACTION="../../options/test_example.co.uk/john.smith@example.co.uk"><INPUT type="Submit" name="logout" value="Log out"></FORM></td>
+ </tr><tr>
+ <td colspan="2">
+
+
+
+
+ <p><strong><font size="+1">You have successfully set your options.</font></strong>
+ </td>
+ </tr>
+</table>
+
+<FORM Method=POST ACTION="../../options/test_example.co.uk/john.smith@example.co.uk">
+<p>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
+ <TR><TD WIDTH="100%" BGCOLOR="#FFF0D0" colspan="2">
+ <FONT COLOR="#000000">
+ <B>Changing your Test membership information</B>
+ </FONT></TD></TR>
+ <tr><td colspan="2">You can change the address that you are subscribed
+ to the mailing list with by entering the new address in the
+ fields below. Note that a confirmation email will be sent to
+ the new address, and the change must be confirmed before it is
+ processed.
+
+ <p>Confirmations time out after about 3 days.
+
+ <p>You can also optionally set or change your real name
+ (i.e. <em>John Smith</em>).
+
+ <p>If you want to make the membership changes for all the
+ lists that you are subscribed to at example.co.uk, turn on the
+ <em>Change globally</em> check box.
+
+ </td></tr>
+ <tr><td><center>
+ <table border="0" cellspacing="2" cellpadding="2" width="80%" cols="2">
+ <tr><td bgcolor="#dddddd"><div align="right">New address:</div></td>
+ <td><INPUT type="Text" name="new-address" size="20" value=""></td>
+ </tr>
+ <tr><td bgcolor="#dddddd"><div align="right">Again to
+ confirm:</div></td>
+ <td><INPUT type="Text" name="confirm-address" size="20" value=""></td>
+ </tr>
+ </tr></table></center>
+ </td>
+ <td><center>
+ <table border="0" cellspacing="2" cellpadding="2" width="80%" cols="2">
+ <tr><td bgcolor="#dddddd"><div align="right">Your name
+ (optional):</div></td>
+ <td><INPUT type="Text" name="fullname" size="20" value=""></td>
+ </tr>
+ </table></center>
+ </td>
+ </tr>
+ <tr><td colspan="2"><center><INPUT type="Submit" name="change-of-address" value="Change My Address and Name">
+ <p><INPUT name="changeaddr-globally" type="CHECKBOX" value="1" >Change globally</center></td>
+ </tr>
+</table>
+
+<p>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
+ <TR><TD WIDTH="50%" BGCOLOR="#FFF0D0"><FONT COLOR="#000000">
+ <B>Unsubscribing from Test</B></td>
+
+ <TD WIDTH="50%" BGCOLOR="#FFF0D0"><FONT COLOR="#000000">
+ <B>Your other example.co.uk subscriptions</B>
+ </FONT></TD></TR>
+
+ <tr><td>
+ Turn on the confirmation checkbox and hit this button to
+ unsubscribe from this mailing list. <strong>Warning:</strong>
+ This action will be taken immediately!
+ <p>
+ <center><INPUT type="Submit" name="unsub" value="Unsubscribe"><br><INPUT name="unsubconfirm" type="CHECKBOX" value="1" ><em>Yes, I really want to unsubscribe</em></center></td>
+ <td>
+ You can view a list of all the other mailing lists at
+ example.co.uk for which you are a member. Use this if you want to
+ make the same membership option changes to this other
+ subscriptions.
+
+ <p>
+ <center><INPUT type="Submit" name="othersubs" value="List my other subscriptions"></center>
+ </TD></TR>
+</table>
+
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
+ <TR><TD COLSPAN=2 WIDTH="100%" BGCOLOR="#FFF0D0"><FONT COLOR="#000000">
+ <B>Your Test Password</B>
+ </FONT></TD></TR>
+
+ <tr valign="TOP"><td WIDTH="50%">
+ <a name=reminder>
+ <center>
+ <h3>Forgotten Your Password?</h3>
+ </center>
+ Click this button to have your password emailed to your
+ membership address.
+ <p>
+ <center>
+ <INPUT type="Submit" name="emailpw" value="Email My Password To Me">
+ </center>
+ </td>
+
+ <td WIDTH="50%">
+ <a name=changepw>
+ <center>
+ <h3>Change Your Password</h3>
+ <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2" WIDTH="70%" COLS=2>
+ <TR><TD BGCOLOR="#dddddd"><div align="right">New
+ password:</div></TD>
+ <TD><INPUT type="Password" name="newpw" size="15"></TD>
+ </TR>
+ <TR>
+ <TD BGCOLOR="#dddddd"><div align="right">Again to
+ confirm:</div></TD>
+ <TD><INPUT type="Password" name="confpw" size="15"></TD>
+ </TR>
+ </table>
+
+ <INPUT type="Submit" name="changepw" value="Change My Password">
+ <p><center><INPUT name="pw-globally" type="CHECKBOX" value="1" >Change globally.
+ </center>
+</TABLE>
+
+<p>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
+ <TR><TD WIDTH="100%" BGCOLOR="#FFF0D0"><FONT COLOR="#000000">
+ <B>Your Test Subscription Options</B>
+ </FONT></TD></TR>
+</table>
+
+<p>
+<i><strong>Current values are checked.</strong></i>
+
+<p>Note that some of the options have a <em>Set globally</em>
+checkbox. Checking this field will cause the changes to be made to
+every mailing list that you are a member of on example.co.uk. Click on
+<em>List my other subscriptions</em> above to see which other mailing
+lists you are subscribed to.
+<p>
+<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="4" WIDTH="100%">
+ <tr><TD BGCOLOR="#cccccc">
+ <a name="disable">
+ <strong>Mail delivery</strong></a><p>
+ Set this option to <em>Enabled</em> to receive messages posted
+ to this mailing list. Set it to <em>Disabled</em> if you want
+ to stay subscribed, but don't want mail delivered to you for a
+ while (e.g. you're going on vacation). If you disable mail
+ delivery, don't forget to re-enable it when you come back; it
+ will not be automatically re-enabled.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="disablemail" value="0" CHECKED>Enabled<br>
+ <input type=radio name="disablemail" value="1">Disabled<p>
+ <INPUT name="deliver-globally" type="CHECKBOX" value="1" ><i>Set globally</i>
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>Set Digest Mode</strong><p>
+ If you turn digest mode on, you'll get posts bundled together
+ (usually one per day but possibly more on busy lists), instead
+ of singly when they're sent. If digest mode is changed from
+ on to off, you may receive one last digest.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="digest" value="0">Off<br>
+ <input type=radio name="digest" value="1" CHECKED>On
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>Get MIME or Plain Text Digests?</strong><p>
+ Your mail reader may or may not support MIME digests. In
+ general MIME digests are preferred, but if you have a problem
+ reading them, select plain text digests.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="mime" value="0" CHECKED>MIME<br>
+ <input type=radio name="mime" value="1">Plain Text<p>
+ <INPUT name="mime-globally" type="CHECKBOX" value="1" ><i>Set globally</i>
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>Receive your own posts to the list?</strong><p>
+ Ordinarily, you will get a copy of every message you post to
+ the list. If you don't want to receive this copy, set this
+ option to <em>No</em>.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="dontreceive" value="1">No<br>
+ <input type=radio name="dontreceive" value="0" CHECKED>Yes
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>Receive acknowledgement mail when you send mail to
+ the list?</strong><p>
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="ackposts" value="0" CHECKED>No<br>
+ <input type=radio name="ackposts" value="1">Yes
+ </td></tr>
+
+ <tr><td bgcolor="#cccccc">
+ <strong>Get password reminder email for this list?</strong><p>
+ Once a month, you will get an email containing a password
+ reminder for every list at this host to which you are
+ subscribed. You can turn this off on a per-list basis by
+ selecting <em>No</em> for this option. If you turn off
+ password reminders for all the lists you are subscribed to, no
+ reminder email will be sent to you.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="remind" value="1">No<br>
+ <input type=radio name="remind" value="0" CHECKED>Yes<p>
+ <INPUT name="remind-globally" type="CHECKBOX" value="1" ><i>Set globally</i>
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>Conceal yourself from subscriber list?</strong><p>
+ When someone views the list membership, your email address is
+ normally shown (in an obscured fashion to thwart spam
+ harvesters). If you do not want your email address to show up
+ on this membership roster at all, select <em>Yes</em> for this option.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="conceal" value="0" CHECKED>No<br>
+ <input type=radio name="conceal" value="1">Yes
+ </td></tr>
+
+ <tr><TD BGCOLOR="#cccccc">
+ <strong>What language do you prefer?</strong><p>
+ </td><td bgcolor="#cccccc">
+ English (USA)
+ </td></tr>
+
+ <tr><td bgcolor="#cccccc">
+ <strong>Which topic categories would you like to subscribe
+ to?</strong><p>
+ By selecting one or more topics, you can filter the
+ traffic on the mailing list, so as to receive only a
+ subset of the messages. If a message matches one of
+ your selected topics, then you will get the message,
+ otherwise you will not.
+
+ <p>If a message does not match any topic, the delivery
+ rule depends on the setting of the option below. If
+ you do not select any topics of interest, you will get
+ all the messages sent to the mailing list.
+ </td><td bgcolor="#cccccc">
+ <em>No topics defined</em>
+ </td></tr>
+
+ <tr><td bgcolor="#cccccc">
+ <strong>Do you want to receive messages that do not match any
+ topic filter?</strong><p>
+
+ This option only takes effect if you've subscribed to
+ at least one topic above. It describes what the
+ default delivery rule is for messages that don't match
+ any topic filter. Selecting <em>No</em> says that if
+ the message does not match any topic filters, then you
+ won't get the message, while selecting <em>Yes</em>
+ says to deliver such non-matching messages to you.
+
+ <p>If no topics of interest are selected above, then
+ you will receive every message sent to the mailing
+ list.
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="rcvtopic" value="0" CHECKED>No<br>
+ <input type=radio name="rcvtopic" value="1">Yes
+ </td></tr>
+
+ <tr><td bgcolor="#cccccc">
+ <strong>Avoid duplicate copies of messages?</strong><p>
+
+ When you are listed explicitly in the <tt>To:</tt> or
+ <tt>Cc:</tt> headers of a list message, you can opt to
+ not receive another copy from the mailing list.
+ Select <em>Yes</em> to avoid receiving copies from the
+ mailing list; select <em>No</em> to receive copies.
+
+ <p>If the list has member personalized messages
+ enabled, and you elect to receive copies, every copy
+ will have a <tt>X-Mailman-Copy: yes</tt> header added
+ to it.
+
+ </td><td bgcolor="#cccccc">
+ <input type=radio name="nodupes" value="0" CHECKED>No<br>
+ <input type=radio name="nodupes" value="1">Yes<p>
+ <INPUT name="nodupes-globally" type="CHECKBOX" value="1" ><i>Set globally</i>
+ </td></tr>
+
+ <tr><TD colspan="2">
+ <center><INPUT type="Submit" name="options-submit" value="Submit My Changes"></center>
+ </td></tr>
+
+</table>
+</center>
+<p>
+</FORM>
+
+<hr><address><a href="../../listinfo/test_example.co.uk">Test</a> list run by <a href="mailto:test-owner@example.co.uk">admin at example.co.uk</a><br><a href="../../admin/test_example.co.uk">Test administrative interface</a> (requires authorization)<br><a href="../../listinfo">Overview of all example.co.uk mailing lists</a><p>
+<table WIDTH="100%" BORDER="0">
+ <tr>
+ <td><img src="/img-sys/mailman.jpg" alt="Delivered by Mailman" border=0><br>version 2.1.14-1</td>
+ <td><img src="/img-sys/PythonPowered.png" alt="Python Powered" border=0></td>
+ <td><img src="/img-sys/gnu-head-tiny.jpg" alt="GNU's Not Unix" border=0></td>
+ </tr>
+</table>
+</address>
+</body>
+</html>
+
View
51 tests/test_setdigest.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test for Services_Mailman setDigest
+--FILE--
+<?php
+
+//settings
+$testURL = 'http://example.co.uk/mailman/admin';
+$testList = 'test_example.co.uk';
+$testPW = 'password';
+
+//get html
+$html_success = file_get_contents('setdigest-success.html');
+$len_success = strlen($html_success);
+$html_fail = file_get_contents('setdigest-fail.html');
+$len_fail = strlen($html_fail);
+
+//set mailman
+require_once 'Services/Mailman.php';
+$mailman = new Services_Mailman($testURL,$testList,$testPW);
+
+//set mock
+require_once 'HTTP/Request2/Adapter/Mock.php';
+$mock = new HTTP_Request2_Adapter_Mock();
+$response = "HTTP/1.1 200 OK\r\n" .
+ "Content-Length: %s\r\n" .
+ "Connection: close\r\n" .
+ "\r\n%s";
+$mock->addResponse(sprintf($response,$len_success,$html_success));
+$mock->addResponse(sprintf($response,$len_fail,$html_fail));
+
+//set mock adapter
+$mailman->request->setAdapter($mock);
+
+// success
+try {
+ $mailman->setDigest('john.smith@example.co.uk',1);
+} catch (Services_Mailman_Exception $e) {
+ echo 'Caught exception: ', $e->getMessage(), "\n";
+}
+
+// fail
+try {
+ $mailman->setDigest('fail@example.co.uk',1);
+} catch (Services_Mailman_Exception $e) {
+ echo 'Caught exception: ', $e->getMessage(), "\n";
+}
+
+?>
+
+--EXPECT--
+Caught exception: Failed to parse HTML.

0 comments on commit 7a87e16

Please sign in to comment.