Make WordPress Core

Changeset 903 in tests


Ignore:
Timestamp:
07/16/2012 05:24:25 PM (12 years ago)
Author:
ryan
Message:

Pinking shears

Location:
trunk
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/exceptions.php

    r883 r903  
    22
    33class WP_Tests_Exception extends PHPUnit_Framework_Exception {
    4    
     4
    55}
    66
  • trunk/includes/mock-mailer.php

    r764 r903  
    22
    33require_once(ABSPATH . '/wp-includes/class-phpmailer.php');
    4    
     4
    55class MockPHPMailer extends PHPMailer {
    66    var $mock_sent = array();
  • trunk/includes/testcase-ajax.php

    r868 r903  
    1616 */
    1717abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
    18    
     18
    1919    /**
    2020     * Last AJAX response.  This is set via echo -or- wp_die.
    21      * @var type 
     21     * @var type
    2222     */
    2323    protected $_last_response = '';
     
    2525    /**
    2626     * List of ajax actions called via POST
    27      * @var type 
     27     * @var type
    2828     */
    2929    protected $_core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed_cache' );
     
    3737    /**
    3838     * List of ajax actions called via GET
    39      * @var type 
     39     * @var type
    4040     */
    4141    protected $_core_actions_post = array(
     
    7777        $this->factory->post->create_many( 5 );
    7878    }
    79    
     79
    8080    /**
    8181     * Tear down the test fixture.
     
    124124     * $this->setExpectedException( 'WPAjaxDieContinueException', 'something contained in $message' );
    125125     * </code>
    126      * @param string $message 
     126     * @param string $message
    127127     */
    128128    public function dieHandler( $message ) {
     
    143143     * Switch between user roles
    144144     * E.g. administrator, editor, author, contributor, subscriber
    145      * @param string $role 
     145     * @param string $role
    146146     */
    147147    protected function _setRole( $role ) {
     
    156156     * Capture the output via output buffering, and if there is any, store
    157157     * it in $this->_last_message.
    158      * @param string $action 
     158     * @param string $action
    159159     */
    160160    protected function _handleAjax($action) {
    161        
     161
    162162        // Start output buffering
    163163        ini_set( 'implicit_flush', false );
  • trunk/tests/test_admin_includes_misc.php

    r796 r903  
    1919                => 'wordpress.org/about/philosophy/#...', // shorten to 32 if > 35 after cleaning
    2020        );
    21         foreach ( $tests as $k => $v ) 
     21        foreach ( $tests as $k => $v )
    2222            $this->assertEquals( $v, url_shorten( $k ) );
    2323    }
  • trunk/tests/test_admin_includes_screen.php

    r877 r903  
    133133        $screen = convert_to_screen( 'comments' );
    134134        $this->assertEquals( $screen->base, 'post' );
    135    
     135
    136136        // Core wins.
    137137        $screen = convert_to_screen( 'edit-tags' );
  • trunk/tests/test_db.php

    r894 r903  
    1313     */
    1414    protected $_queries = array();
    15    
     15
    1616    /**
    1717     * Set up the test fixture
     
    5252        // Save the current locale
    5353        $current_locale = setlocale( LC_ALL, NULL );
    54        
     54
    5555        // Switch to Russian
    5656        $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES' );
    5757        if ( false === $flag )
    5858            $this->markTestSkipped( 'No European languages available for testing' );
    59        
     59
    6060        // Try an update query
    6161        $wpdb->suppress_errors( true );
    62         $wpdb->update( 
    63             'test_table', 
    64             array( 'float_column' => 0.7 ), 
    65             array( 'meta_id' => 5 ), 
    66             array( '%f' ), 
    67             array( '%d' ) 
     62        $wpdb->update(
     63            'test_table',
     64            array( 'float_column' => 0.7 ),
     65            array( 'meta_id' => 5 ),
     66            array( '%f' ),
     67            array( '%d' )
    6868        );
    6969        $wpdb->suppress_errors( false );
    70        
     70
    7171        // Ensure the float isn't 0,700
    7272        $this->assertContains( '0.700', array_pop( $this->_queries ) );
  • trunk/tests/test_http.php

    r894 r903  
    220220            return;
    221221        }
    222    
     222
    223223        $actual = WP_HTTP::make_absolute_url( $relative_url, $absolute_url );
    224224        $this->assertEquals( $expected, $actual );
     
    230230            array( 'http://site.com/', 'http://example.com/', 'http://site.com/' ), // Absolute URL provided
    231231            array( '/location', '', '/location' ), // No current url provided
    232            
     232
    233233            array( '', 'http://example.com', 'http://example.com/' ), // No location provided
    234            
     234
    235235            // Location provided relative to site root
    236236            array( '/root-relative-link.ext', 'http://example.com/', 'http://example.com/root-relative-link.ext' ),
    237237            array( '/root-relative-link.ext?with=query', 'http://example.com/index.ext?query', 'http://example.com/root-relative-link.ext?with=query' ),
    238            
     238
    239239            // Location provided relative to current file/directory
    240240            array( 'relative-file.ext', 'http://example.com/', 'http://example.com/relative-file.ext' ),
    241241            array( 'relative-file.ext', 'http://example.com/filename', 'http://example.com/relative-file.ext' ),
    242242            array( 'relative-file.ext', 'http://example.com/directory/', 'http://example.com/directory/relative-file.ext' ),
    243            
     243
    244244            // Location provided relative to current file/directory but in a parent directory
    245245            array( '../file-in-parent.ext', 'http://example.com', 'http://example.com/file-in-parent.ext' ),
     
    254254            array( '../../file-in-grand-parent.ext', 'http://example.com/directory/filename/', 'http://example.com/file-in-grand-parent.ext' ),
    255255            array( '../../file-in-grand-parent.ext', 'http://example.com/directory1/directory2/filename', 'http://example.com/file-in-grand-parent.ext' ),
    256            
     256
    257257            // Query strings should attach, or replace existing query string.
    258258            array( '?query=string', 'http://example.com', 'http://example.com/?query=string' ),
     
    260260            array( '?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/file.ext?query=string' ),
    261261            array( 'otherfile.ext?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/otherfile.ext?query=string' ),
    262            
     262
    263263            // A file with a leading dot
    264264            array( '.ext', 'http://example.com/', 'http://example.com/.ext' )
  • trunk/tests/test_image.php

    r894 r903  
    125125    function test_utf8_iptc_tags() {
    126126
    127         // trilingual UTF-8 text in the ITPC caption-abstract field 
     127        // trilingual UTF-8 text in the ITPC caption-abstract field
    128128        $out = wp_read_image_metadata(DIR_TESTDATA.'/images/test-image-iptc.jpg');
    129129
    130130        $this->assertEquals('This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $out['caption']);
    131131    }
    132    
     132
    133133    /**
    134134     * wp_read_image_metadata() should false if the image file doesn't exist
  • trunk/tests/test_includes_balance_tags.php

    r894 r903  
    2828        }
    2929    }
    30  
     30
    3131    /**
    3232     * If a recognized valid single tag appears unclosed, it should get self-closed
  • trunk/tests/test_includes_canonical.php

    r894 r903  
    3636        // Already created by install defaults:
    3737        // $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) );
    38        
     38
    3939        $this->term_ids = array();
    4040
     
    5353
    5454        $this->factory->post->create( array( 'post_date' => '2008-09-05 00:00:00' ) );
    55        
     55
    5656        $this->factory->post->create( array( 'import_id' => 123 ) );
    5757        $this->factory->post->create( array( 'import_id' => 1 ) );
    5858        $this->factory->post->create( array( 'import_id' => 358 ) );
    59        
     59
    6060        $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'sample-page' ) );
    6161        $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
     
    7575        $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-a' ) );
    7676        $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-b' ) );
    77        
     77
    7878        $this->factory->term->create( array( 'name' => 'post-formats' ) );
    7979    }
     
    106106
    107107        $ticket_ref = ($ticket > 0) ? 'Ticket #' . $ticket : null;
    108        
     108
    109109        if ( is_string($expected) )
    110110            $expected = array('url' => $expected);
     
    360360         *      (string) expected redirect location
    361361         * [3]: (optional) The ticket the test refers to, Can be skipped if unknown.
    362          */     
     362         */
    363363        return array(
    364364            array( '/?p=123', '/?p=123' ),
  • trunk/tests/test_includes_class-wp-xmlrpc-server.php

    r877 r903  
    1111        $myxmlrpcserver = new wp_xmlrpc_server();
    1212        $result = $myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
    13        
     13
    1414        $this->assertInstanceOf( 'IXR_Error', $result );
    1515        $this->assertEquals( 405, $result->code );
  • trunk/tests/test_includes_formatting.php

    r894 r903  
    170170            'In his famous speech “You and Your research” (here:
    171171            http://www.cs.virginia.edu/~robins/YouAndYourResearch.html)
    172             Richard Hamming wrote about people getting more done with their doors closed, but', 
     172            Richard Hamming wrote about people getting more done with their doors closed, but',
    173173        );
    174174        $urls_expected = array(
     
    184184            'In his famous speech “You and Your research” (here:
    185185            <a href="http://www.cs.virginia.edu/~robins/YouAndYourResearch.html" rel="nofollow">http://www.cs.virginia.edu/~robins/YouAndYourResearch.html</a>)
    186             Richard Hamming wrote about people getting more done with their doors closed, but', 
     186            Richard Hamming wrote about people getting more done with their doors closed, but',
    187187        );
    188188        foreach ($urls_before as $key => $url) {
     
    754754     *
    755755     * @ticket 19855
    756      */ 
     756     */
    757757    public function test_skip_pre_elements() {
    758758        $code = file_get_contents( DIR_TESTDATA . '/formatting/sizzle.js' );
    759759        $code = str_replace( "\r", '', $code );
    760760        $code = htmlentities( $code );
    761        
     761
    762762        // Not wrapped in <p> tags
    763763        $str = "<pre>$code</pre>";
     
    766766        // Text before/after is wrapped in <p> tags
    767767        $str = "Look at this code\n\n<pre>$code</pre>\n\nIsn't that cool?";
    768        
     768
    769769        // Expected text after wpautop
    770770        $expected = '<p>Look at this code</p>' . "\n<pre>" . $code . "</pre>\n" . '<p>Isn\'t that cool?</p>';
     
    776776        $this->assertEquals( $expected, trim( wpautop( $str ) ) );
    777777    }
    778    
     778
    779779    /**
    780780     * wpautop() Should not add <br/> to "<input>" elements
    781781     *
    782782     * @ticket 16456
    783      */ 
     783     */
    784784    public function test_skip_input_elements() {
    785785        $str = 'Username: <input type="text" id="username" name="username" /><br />Password: <input type="password" id="password1" name="password1" />';
     
    14581458
    14591459        $text = 'This text contains<style>#css { width:expression(alert("css")) }</style>. It should go.';
    1460         $this->assertEquals( $trimmed, wp_trim_words( $text ) );       
     1460        $this->assertEquals( $trimmed, wp_trim_words( $text ) );
    14611461    }
    14621462
     
    15261526        // acute accent
    15271527        $this->assertEquals( 'AaAaEeOoOoUu', remove_accents( 'ẤấẮắẾếỐốỚớỨứ' ) );
    1528         // dot below 
     1528        // dot below
    15291529        $this->assertEquals( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẠạẬậẶặẸẹỆệỊịỌọỘộỢợỤụỰựỴỵ' ) );
    15301530    }
  • trunk/tests/test_includes_functions.php

    r894 r903  
    462462            $this->assertEquals( $expected[ $header ], $value, $header );
    463463    }
    464        
     464
    465465    function test_get_file_data_cr_line_endings() {
    466466        $headers = array( 'SomeHeader' => 'Some Header', 'Description' => 'Description', 'Author' => 'Author' );
  • trunk/tests/test_includes_kses.php

    r894 r903  
    2020            'title' => 'title',
    2121        );
    22        
     22
    2323        foreach ( $attributes as $name => $value ) {
    2424            $string = "<address $name='$value'>1 WordPress Avenue, The Internet.</address>";
     
    4444            'target' => '_blank',
    4545        );
    46        
     46
    4747        foreach ( $attributes as $name => $value ) {
    4848            $string = "<a $name='$value'>I link this</a>";
  • trunk/tests/test_includes_media.php

    r883 r903  
    3030
    3131  function test_img_caption_shortcode_with_old_format() {
    32     $result = img_caption_shortcode( 
    33       array( 'width' => 20, 'caption' => $this->caption ) 
     32    $result = img_caption_shortcode(
     33      array( 'width' => 20, 'caption' => $this->caption )
    3434    );
    3535    $this->assertEquals( 2, preg_match_all( '/wp-caption/', $result, $_r ) );
     
    4040
    4141  function test_img_caption_shortcode_with_old_format_id_and_align() {
    42     $result = img_caption_shortcode( 
    43       array( 
     42    $result = img_caption_shortcode(
     43      array(
    4444        'width' => 20,
    4545        'caption' => $this->caption,
     
    5454
    5555  function test_new_img_caption_shortcode_with_html_caption() {
    56     $result = img_caption_shortcode( 
    57       array( 'width' => 20, 'caption' => $this->html_content ) 
     56    $result = img_caption_shortcode(
     57      array( 'width' => 20, 'caption' => $this->html_content )
    5858    );
    5959    $our_preg = preg_quote( $this->html_content );
     
    6363
    6464  function test_new_img_caption_shortcode_new_format() {
    65     $result = img_caption_shortcode( 
     65    $result = img_caption_shortcode(
    6666      array( 'width' => 20 ),
    6767      $this->img_content . $this->html_content
     
    7676  function test_new_img_caption_shortcode_new_format_and_linked_image() {
    7777    $linked_image = "<a href='#'>{$this->img_content}</a>";
    78     $result = img_caption_shortcode( 
     78    $result = img_caption_shortcode(
    7979      array( 'width' => 20 ),
    8080      $linked_image . $this->html_content
     
    8989  function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() {
    9090    $linked_image = "<a href='#'>{$this->img_content}</a>";
    91     $result = img_caption_shortcode( 
     91    $result = img_caption_shortcode(
    9292      array( 'width' => 20 ),
    9393      $linked_image . "\n\n" . $this->html_content
  • trunk/tests/test_includes_post.php

    r894 r903  
    476476    function tearDown() {
    477477        // Remove all uploads.
    478         $uploads = wp_upload_dir(); 
     478        $uploads = wp_upload_dir();
    479479        foreach ( scandir( $uploads['basedir'] ) as $file )
    480             _rmdir( $uploads['basedir'] . '/' . $file ); 
     480            _rmdir( $uploads['basedir'] . '/' . $file );
    481481
    482482        parent::tearDown();
  • trunk/tests/test_includes_wp-scripts.php

    r896 r903  
    4242        $this->assertEquals("", get_echo('wp_print_scripts'));
    4343    }
    44    
     44
    4545    /**
    4646     * Test the different protocol references in wp_enqueue_script
     
    6363        wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    6464        $expected  .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
    65        
     65
    6666        // Try with an automatic protocol reference (//)
    6767        wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
     
    7676        wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    7777        $expected  .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
    78        
     78
    7979        // Go!
    8080        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
  • trunk/tests/test_includes_wp-styles.php

    r896 r903  
    3535        $expected .= "<link rel='stylesheet' id='no-deps-null-version-css'  href='http://example.com' type='text/css' media='all' />\n";
    3636        $expected .= "<link rel='stylesheet' id='no-deps-null-version-print-media-css'  href='http://example.com' type='text/css' media='print' />\n";
    37        
     37
    3838        $this->assertEquals($expected, get_echo('wp_print_styles'));
    3939
     
    4141        $this->assertEquals("", get_echo('wp_print_styles'));
    4242    }
    43    
     43
    4444    /**
    4545     * Test the different protocol references in wp_enqueue_style
     
    6262        wp_enqueue_style( 'reset-css-https', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' );
    6363        $expected  .= "<link rel='stylesheet' id='reset-css-https-css'  href='http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css?ver=$ver' type='text/css' media='all' />\n";
    64        
     64
    6565        // Try with an automatic protocol reference (//)
    6666        wp_enqueue_style( 'reset-css-doubleslash', '//yui.yahooapis.com/2.8.1/build/reset/reset-min.css' );
  • trunk/tests/test_meta.php

    r877 r903  
    7575        $expected .= "foo bar\n";
    7676        $expected .= "foo";
    77        
     77
    7878        $this->assertEquals($expected, strip_ws($in));
    7979
  • trunk/tests/test_ms.php

    r894 r903  
    3232
    3333        // update the blog count cache to use get_blog_count()
    34         wp_update_network_counts(); 
     34        wp_update_network_counts();
    3535        $this->assertEquals( 4 + 1, (int) get_blog_count() );
    3636
     
    5353
    5454        // update the blog count cache to use get_blog_count()
    55         wp_update_network_counts(); 
     55        wp_update_network_counts();
    5656        $this->assertEquals( 1, get_blog_count() );
    5757    }
     
    153153        activate_plugin($path, '', $network_wide = true);
    154154        $active_plugins = wp_get_active_network_plugins();
    155         $this->assertEquals( Array(WP_PLUGIN_DIR . '/hello.php'), $active_plugins ); 
     155        $this->assertEquals( Array(WP_PLUGIN_DIR . '/hello.php'), $active_plugins );
    156156
    157157        //deactivate the plugin
     
    189189
    190190    function test_wp_schedule_update_network_counts() {
    191         $this->assertFalse(wp_next_scheduled('update_network_counts')); 
     191        $this->assertFalse(wp_next_scheduled('update_network_counts'));
    192192
    193193        // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set
    194194        wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
    195195
    196         $this->assertInternalType('int', wp_next_scheduled('update_network_counts'));   
     196        $this->assertInternalType('int', wp_next_scheduled('update_network_counts'));
    197197    }
    198198
     
    203203
    204204        update_site_option('registration', 'all');
    205         $this->assertTrue( users_can_register_signup_filter() );   
     205        $this->assertTrue( users_can_register_signup_filter() );
    206206
    207207        update_site_option('registration', 'user');
     
    209209
    210210        update_site_option('registration', 'none');
    211         $this->assertFalse( users_can_register_signup_filter() );       
     211        $this->assertFalse( users_can_register_signup_filter() );
    212212    }
    213213
     
    333333        $this->assertEquals( 'example.com', $blog->domain );
    334334        $this->assertEquals( 'my_path/', $blog->path );
    335         $this->assertEquals( '0', $blog->spam );   
     335        $this->assertEquals( '0', $blog->spam );
    336336
    337337        $result = update_blog_details( $blog_id, array('domain' => 'example2.com','spam' => 1) );
  • trunk/tests/test_option.php

    r897 r903  
    1414
    1515    function __return_foo() {
    16         return 'foo';   
     16        return 'foo';
    1717    }
    1818
     
    8686class TestSiteOption extends WP_UnitTestCase {
    8787    function __return_foo() {
    88         return 'foo';   
     88        return 'foo';
    8989    }
    9090
     
    169169
    170170        $this->assertEquals( get_site_option( $option, $default ), $default );
    171         $this->assertFalse( get_site_option( $option ) );   
     171        $this->assertFalse( get_site_option( $option ) );
    172172    }
    173173}
  • trunk/tests/test_query.php

    r894 r903  
    240240        $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
    241241    }
    242    
     242
    243243    // FIXME: what is this for?
    244244    // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
  • trunk/tests/test_query_results.php

    r894 r903  
    2222        $this->factory->post->create( array( 'post_title' => 'cats-b-and-c', 'post_date' => '2009-02-01 00:00:00', 'post_category' => array( $cat_b, $cat_c ) ) );
    2323        $this->factory->post->create( array( 'post_title' => 'cats-a-and-c', 'post_date' => '2009-03-01 00:00:00', 'post_category' => array( $cat_a, $cat_c ) ) );
    24         $this->factory->post->create( array( 'post_title' => 'cat-a', 'post_date' => '2009-04-01 00:00:00', 'post_category' => array( $cat_a ) ) );     
     24        $this->factory->post->create( array( 'post_title' => 'cat-a', 'post_date' => '2009-04-01 00:00:00', 'post_category' => array( $cat_a ) ) );
    2525        $this->factory->post->create( array( 'post_title' => 'cat-b', 'post_date' => '2009-05-01 00:00:00', 'post_category' => array( $cat_b ) ) );
    2626        $this->factory->post->create( array( 'post_title' => 'cat-c', 'post_date' => '2009-06-01 00:00:00', 'post_category' => array( $cat_c ) ) );
  • trunk/tests/test_shortcode.php

    r893 r903  
    3939            'baz' => 'default baz',
    4040        ), $atts));
    41    
     41
    4242        return "foo = {$foo}";
    4343    }
  • trunk/tests/test_uploads.php

    r901 r903  
    2626
    2727        // Remove year/month folders created by wp_upload_dir().
    28         $uploads = wp_upload_dir(); 
     28        $uploads = wp_upload_dir();
    2929        foreach ( scandir( $uploads['basedir'] ) as $file )
    30             _rmdir( $uploads['basedir'] . '/' . $file ); 
     30            _rmdir( $uploads['basedir'] . '/' . $file );
    3131        _rmdir( ABSPATH . 'foo/' );
    3232    }
  • trunk/tests/test_user.php

    r896 r903  
    160160        }
    161161    }
    162    
     162
    163163    /**
    164164     * Test the magic __unset method
     
    188188        $this->assertNotEmpty( $user->ID );
    189189        unset( $user->ID );
    190         $this->assertEmpty( $user->ID );       
     190        $this->assertEmpty( $user->ID );
    191191    }
    192192
Note: See TracChangeset for help on using the changeset viewer.