Make WordPress Core

Changeset 909 in tests for trunk/tests/auth.php


Ignore:
Timestamp:
07/19/2012 01:52:37 AM (12 years ago)
Author:
nacin
Message:

Complete the renaming described in [904].

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/auth.php

    r904 r909  
    44 * @group pluggable
    55 */
    6 class TestAuthFunctions extends WP_UnitTestCase {
     6class Tests_Auth extends WP_UnitTestCase {
    77    var $user_id;
    88
     
    4343    }
    4444}
    45 
    46 /**
    47  * @group pluggable
    48  * @group mail
    49  * @ticket UT47
    50  */
    51 class TestMailFunctions extends WP_UnitTestCase {
    52     function setUp() {
    53         parent::setUp();
    54     }
    55 
    56     function test_wp_mail_custom_boundaries() {
    57         $to = 'user@example.com';
    58         $subject = 'Test email with custom boundaries';
    59         $headers  = '' . "\n";
    60         $headers .= 'MIME-Version: 1.0' . "\n";
    61         $headers .= 'Content-Type: multipart/mixed; boundary="----=_Part_4892_25692638.1192452070893"' . "\n";
    62         $headers .= "\n";
    63         $body  = "\n";
    64         $body .= '------=_Part_4892_25692638.1192452070893' . "\n";
    65         $body .= 'Content-Type: text/plain; charset=ISO-8859-1' . "\n";
    66         $body .= 'Content-Transfer-Encoding: 7bit' . "\n";
    67         $body .= 'Content-Disposition: inline' . "\n";
    68         $body .= "\n";
    69         $body .= 'Here is a message with an attachment of a binary file.' . "\n";
    70         $body .= "\n";
    71         $body .= '------=_Part_4892_25692638.1192452070893' . "\n";
    72         $body .= 'Content-Type: image/x-icon; name=favicon.ico' . "\n";
    73         $body .= 'Content-Transfer-Encoding: base64' . "\n";
    74         $body .= 'Content-Disposition: attachment; filename=favicon.ico' . "\n";
    75         $body .= "\n";
    76         $body .= 'AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAA' . "\n";
    77         $body .= 'AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA' . "\n";
    78         $body .= '/wD/AP//AAD///8A//3/AP39/wD6/f8A+P3/AP/8/wD9/P8A+vz/AP/7/wD/+v8A/vr/APz6/wD4' . "\n";
    79         $body .= '+v8A+/n/APP5/wD/+P8A+vj/AO/4/wDm+P8A2fj/AP/3/wD/9v8A9vb/AP/1/wD69f8A9PT/AO30' . "\n";
    80         $body .= '/wD/8/8A//L/APnx/wD28P8A///+APj//gD2//4A9P/+AOP//gD//f4A6f/9AP///AD2//wA8//8' . "\n";
    81         $body .= 'APf9/AD///sA/v/7AOD/+wD/+vsA9/X7APr/+gDv/voA///5AP/9+QD/+/kA+e35AP//+ADm//gA' . "\n";
    82         $body .= '4f/4AP/9+AD0+/gA///3APv/9wDz//cA8f/3AO3/9wD/8fcA//32AP369gDr+vYA8f/1AOv/9QD/' . "\n";
    83         $body .= '+/UA///0APP/9ADq//QA///zAP/18wD///IA/fzyAP//8QD///AA9//wAPjw8AD//+8A8//vAP//' . "\n";
    84         $body .= '7gD9/+4A9v/uAP/u7gD//+0A9v/tAP7/6wD/+eoA///pAP//6AD2/+gA//nnAP/45wD38eYA/fbl' . "\n";
    85         $body .= 'AP/25AD29uQA7N/hAPzm4AD/690AEhjdAAAa3AAaJdsA//LXAC8g1gANH9YA+dnTAP/n0gDh5dIA' . "\n";
    86         $body .= 'DyjSABkk0gAdH9EABxDRAP/l0AAAJs4AGRTOAPPczQAAKs0AIi7MAA4UywD56soA8tPKANTSygD/' . "\n";
    87         $body .= '18kA6NLHAAAjxwDj28QA/s7CAP/1wQDw3r8A/9e8APrSrwDCtqoAzamjANmPiQDQj4YA35mBAOme' . "\n";
    88         $body .= 'fgDHj3wA1qR6AO+sbwDpmm8A2IVlAKmEYgCvaFoAvHNXAEq2VgA5s1UAPbhQAFWtTwBStU0ARbNN' . "\n";
    89         $body .= 'AEGxTQA7tEwAObZIAEq5RwDKdEYAULhDANtuQgBEtTwA1ls3ALhgMQCxNzEA2FsvAEC3LQB0MCkA' . "\n";
    90         $body .= 'iyYoANZTJwDLWyYAtjMlALE6JACZNSMAuW4iANlgIgDoWCEAylwgAMUuIAD3Vh8A52gdALRCHQCx' . "\n";
    91         $body .= 'WhwAsEkcALU4HACMOBwA0V4bAMYyGgCPJRoA218ZAJM7FwC/PxYA0msVAM9jFQD2XBUAqioVAIAf' . "\n";
    92         $body .= 'FQDhYRQAujMTAMUxEwCgLBMAnxIPAMsqDgCkFgsA6GMHALE2BAC9JQAAliIAAFYTAAAAAAAAAAAA' . "\n";
    93         $body .= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' . "\n";
    94         $body .= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/' . "\n";
    95         $body .= '//8AsbGxsbGxsbGxsbGxsbGxd7IrMg8PDw8PDw8PUBQeJXjQYE9PcKPM2NfP2sWhcg+BzTE7dLjb' . "\n";
    96         $body .= 'mG03YWaV4JYye8MPbsLZlEouKRRCg9SXMoW/U53enGRAFzCRtNO7mTiAyliw30gRTg9VbJCKfYs0' . "\n";
    97         $body .= 'j9VmuscfLTFbIy8SOhA0Inq5Y77GNBMYIxQUJzM2Vxx2wEmfyCYWMRldXCg5MU0aicRUms58SUVe' . "\n";
    98         $body .= 'RkwjPBRSNIfBMkSgvWkyPxVHFIaMSx1/0S9nkq7WdWo1a43Jt2UqgtJERGJ5m6K8y92znpNWIYS1' . "\n";
    99         $body .= 'UQ89Mmg5cXNaX0EkGyyI3KSsp6mvpaqosaatq7axsQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' . "\n";
    100         $body .= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' . "\n";
    101         $body .= '------=_Part_4892_25692638.1192452070893--' . "\n";
    102         $body .= "\n";
    103 
    104         unset($GLOBALS['phpmailer']->mock_sent);
    105         $_SERVER['SERVER_NAME'] = 'example.com';
    106         wp_mail($to, $subject, $body, $headers);
    107 
    108         // We need some better assertions here but these catch the failure for now.
    109         $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']);
    110         $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'boundary="----=_Part_4892_25692638.1192452070893"') > 0);
    111         $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset=""') > 0);
    112         unset( $_SERVER['SERVER_NAME'] );
    113     }
    114 
    115     /**
    116      * @ticket 15448
    117      */
    118     function test_wp_mail_plain_and_html() {
    119 
    120         $to = 'user@example.com';
    121         $subject = 'Test email with plain text and html versions';
    122         $messages = array( 'text/plain' => 'Here is some plain text.',
    123                        'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' );
    124 
    125         unset($GLOBALS['phpmailer']->mock_sent);
    126         $_SERVER['SERVER_NAME'] = 'example.com';
    127         wp_mail( $to, $subject, $messages );
    128 
    129         preg_match( '/boundary="(.*)"/', $GLOBALS['phpmailer']->mock_sent[0]['header'], $matches);
    130         $boundry = $matches[1];
    131         $body = '--' . $boundry . '
    132 Content-Type: text/plain; charset = "UTF-8"
    133 Content-Transfer-Encoding: 8bit
    134 
    135 Here is some plain text.
    136 
    137 
    138 --' . $boundry . '
    139 Content-Type: text/html; charset = "UTF-8"
    140 Content-Transfer-Encoding: 8bit
    141 
    142 <html><head></head><body>Here is the HTML ;-)<body></html>
    143 
    144 
    145 
    146 --' . $boundry . '--
    147 ';
    148         // We need some better assertions here but these test the behaviour for now.
    149         $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']);
    150         unset( $_SERVER['SERVER_NAME'] );
    151     }
    152 
    153     /**
    154      * @ticket 17305
    155      */
    156     function test_wp_mail_rfc2822_addresses() {
    157 
    158         $to = "Name <address@tld.com>";
    159         $from = "Another Name <another_address@different-tld.com>";
    160         $cc = "The Carbon Guy <cc@cc.com>";
    161         $bcc = "The Blind Carbon Guy <bcc@bcc.com>";
    162         $subject = "RFC2822 Testing";
    163         $message = "My RFC822 Test Message";
    164         $headers[] = "From: {$from}";
    165         $headers[] = "CC: {$cc}";
    166         $headers[] = "BCC: {$bcc}";
    167 
    168         unset($GLOBALS['phpmailer']->mock_sent);
    169         $_SERVER['SERVER_NAME'] = 'example.com';
    170         wp_mail( $to, $subject, $message, $headers );
    171 
    172         // WordPress 3.2 and later correctly split the address into the two parts and send them seperately to PHPMailer
    173         // Earlier versions of PHPMailer were not touchy about the formatting of these arguments.
    174         if ( version_compare( $GLOBALS['wp_version'], '3.1.9', '>' ) ) {
    175             $this->assertEquals('address@tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    176             $this->assertEquals('Name', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][1]);
    177             $this->assertEquals('cc@cc.com', $GLOBALS['phpmailer']->mock_sent[0]['cc'][0][0]);
    178             $this->assertEquals('The Carbon Guy', $GLOBALS['phpmailer']->mock_sent[0]['cc'][0][1]);
    179             $this->assertEquals('bcc@bcc.com', $GLOBALS['phpmailer']->mock_sent[0]['bcc'][0][0]);
    180             $this->assertEquals('The Blind Carbon Guy', $GLOBALS['phpmailer']->mock_sent[0]['bcc'][0][1]);
    181         } else {
    182             $this->assertEquals($to, $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    183             $this->assertEquals($cc, $GLOBALS['phpmailer']->mock_sent[0]['cc'][0][0]);
    184             $this->assertEquals($bcc, $GLOBALS['phpmailer']->mock_sent[0]['bcc'][0][0]);
    185         }
    186 
    187         $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']);
    188         unset( $_SERVER['SERVER_NAME'] );
    189     }
    190 
    191     /**
    192      * @ticket 17305
    193      */
    194     function test_wp_mail_multiple_rfc2822_to_addresses() {
    195 
    196         $to = "Name <address@tld.com>, Another Name <another_address@different-tld.com>";
    197         $subject = "RFC2822 Testing";
    198         $message = "My RFC822 Test Message";
    199 
    200         unset($GLOBALS['phpmailer']->mock_sent);
    201         $_SERVER['SERVER_NAME'] = 'example.com';
    202         wp_mail( $to, $subject, $message );
    203 
    204         // WordPress 3.2 and later correctly split the address into the two parts and send them seperately to PHPMailer
    205         // Earlier versions of PHPMailer were not touchy about the formatting of these arguments.
    206         if ( version_compare( $GLOBALS['wp_version'], '3.1.9', '>' ) ) {
    207             $this->assertEquals('address@tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    208             $this->assertEquals('Name', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][1]);
    209             $this->assertEquals('another_address@different-tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][0]);
    210             $this->assertEquals('Another Name', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][1]);
    211         } else {
    212             $this->assertEquals('Name <address@tld.com>', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    213             $this->assertEquals('Another Name <another_address@different-tld.com>', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][0]);
    214         }
    215 
    216         $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']);
    217         unset( $_SERVER['SERVER_NAME'] );
    218     }
    219 
    220     function test_wp_mail_multiple_to_addresses() {
    221         $to = "address@tld.com, another_address@different-tld.com";
    222         $subject = "RFC2822 Testing";
    223         $message = "My RFC822 Test Message";
    224 
    225         unset($GLOBALS['phpmailer']->mock_sent);
    226         $_SERVER['SERVER_NAME'] = 'example.com';
    227         wp_mail( $to, $subject, $message );
    228 
    229         $this->assertEquals('address@tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    230         $this->assertEquals('another_address@different-tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][0]);
    231         $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']);
    232         unset( $_SERVER['SERVER_NAME'] );
    233     }
    234 
    235     /**
    236      * @ticket 18463
    237      */
    238     function test_wp_mail_to_address_no_name() {
    239 
    240         $to = "<address@tld.com>";
    241         $subject = "RFC2822 Testing";
    242         $message = "My RFC822 Test Message";
    243 
    244         unset($GLOBALS['phpmailer']->mock_sent);
    245         $_SERVER['SERVER_NAME'] = 'example.com';
    246         wp_mail( $to, $subject, $message );
    247 
    248         // Old PHPMailer blindly accepts the address, the new one santizes it
    249         if ( version_compare( $GLOBALS['wp_version'], '3.1.9', '>' ) )
    250             $this->assertEquals('address@tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    251         else
    252             $this->assertEquals('<address@tld.com>', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]);
    253         $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']);
    254         unset( $_SERVER['SERVER_NAME'] );
    255     }
    256 }
    257 
    258 /**
    259  * @group pluggable
    260  */
    261 class TestRedirectFunctions extends WP_UnitTestCase {
    262     function test_wp_sanitize_redirect() {
    263         $this->assertEquals('http://example.com/watchthelinefeedgo', wp_sanitize_redirect('http://example.com/watchthelinefeed%0Ago'));
    264         $this->assertEquals('http://example.com/watchthelinefeedgo', wp_sanitize_redirect('http://example.com/watchthelinefeed%0ago'));
    265         $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0Dgo'));
    266         $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0dgo'));
    267         //Nesting checks
    268         $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0ddgo'));
    269         $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0DDgo'));
    270     }
    271 }
Note: See TracChangeset for help on using the changeset viewer.