Make WordPress Core

Changeset 45013 for branches/4.0


Ignore:
Timestamp:
03/26/2019 12:45:57 AM (6 years ago)
Author:
johnbillion
Message:

Build/Test tools: Fix the Travis CI build for the 4.0 branch.

Among other fixes, this backports [29860], [29869], [29954], [30160], [30530].

Fixes #46646

Location:
branches/4.0
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/package.json

    r44886 r45013  
    2626    "grunt-legacy-util": "^0.2.0",
    2727    "grunt-patch-wordpress": "~0.2.1",
    28     "grunt-sass": "~0.14.0",
     28    "grunt-sass": "~0.16.0",
    2929    "matchdep": "~0.3.0"
    3030  }
  • branches/4.0/phpunit.xml.dist

    r25165 r45013  
    2626        <log type="junit" target="tests/phpunit/build/logs/junit.xml" logIncompleteSkipped="false"/>
    2727    </logging>
     28    <php>
     29        <const name="WP_RUN_CORE_TESTS" value="1" />
     30    </php>
    2831</phpunit>
  • branches/4.0/tests/phpunit/includes/testcase.php

    r42065 r45013  
    3838        $this->factory = new WP_UnitTest_Factory;
    3939        $this->clean_up_global_scope();
     40
     41        /*
     42         * When running core tests, ensure that post types and taxonomies
     43         * are reset for each test. We skip this step for non-core tests,
     44         * given the large number of plugins that register post types and
     45         * taxonomies at 'init'.
     46         */
     47        if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
     48            $this->reset_post_types();
     49            $this->reset_taxonomies();
     50        }
     51
    4052        $this->start_transaction();
    4153        $this->expectDeprecated();
    4254        add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
     55    }
     56
     57    /**
     58     * Unregister existing post types and register defaults.
     59     *
     60     * Run before each test in order to clean up the global scope, in case
     61     * a test forgets to unregister a post type on its own, or fails before
     62     * it has a chance to do so.
     63     */
     64    protected function reset_post_types() {
     65        foreach ( get_post_types() as $pt ) {
     66            _unregister_post_type( $pt );
     67        }
     68        create_initial_post_types();
     69    }
     70
     71    /**
     72     * Unregister existing taxonomies and register defaults.
     73     *
     74     * Run before each test in order to clean up the global scope, in case
     75     * a test forgets to unregister a taxonomy on its own, or fails before
     76     * it has a chance to do so.
     77     */
     78    protected function reset_taxonomies() {
     79        foreach ( get_taxonomies() as $tax ) {
     80            _unregister_taxonomy( $tax );
     81        }
     82        create_initial_taxonomies();
    4383    }
    4484
  • branches/4.0/tests/phpunit/multisite.xml

    r25294 r45013  
    2626        </exclude>
    2727    </groups>
     28    <php>
     29        <const name="WP_RUN_CORE_TESTS" value="1" />
     30    </php>
    2831</phpunit>
  • branches/4.0/tests/phpunit/tests/canonical/https.php

    r28713 r45013  
    4545     * @ticket 27954
    4646     */
    47     public function test_http_request_with_https_home() {
    48 
    49         add_filter( 'home_url', array( $this, 'set_https' ) );
    50 
    51         $redirect = redirect_canonical( $this->http, false );
    52 
    53         $this->assertEquals( $redirect, $this->https );
    54 
    55         remove_filter( 'home_url', array( $this, 'set_https' ) );
    56 
    57     }
    58 
    59     /**
    60      * @ticket 27954
    61      */
    6247    public function test_https_request_with_https_home() {
    6348
  • branches/4.0/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php

    r25002 r45013  
    3434    function test_handles_non_entity_ampersands() {
    3535        $this->assertEquals("penn-teller-bull", sanitize_title_with_dashes("penn & teller bull"));
    36     }
    37 
    38     /**
    39      * @ticket 10823
    40      */
    41     function test_strips_entities() {
    42         $this->assertEquals("no-entities-here", sanitize_title_with_dashes("No &nbsp; Entities &ndash; Here &amp;"));
    43         $this->assertEquals("one-two", sanitize_title_with_dashes("One &amp; Two", '', 'save'));
    44         $this->assertEquals("one-two", sanitize_title_with_dashes("One &#123; Two;", '', 'save'));
    45         $this->assertEquals("one-two", sanitize_title_with_dashes("One & Two;", '', 'save'));
    46         $this->assertEquals("one-two", sanitize_title_with_dashes("One Two™;", '', 'save'));
    47         $this->assertEquals("one-two", sanitize_title_with_dashes("One &&amp; Two;", '', 'save'));
    48         $this->assertEquals("onetwo", sanitize_title_with_dashes("One&Two", '', 'save'));
    49         $this->assertEquals("onetwo-test", sanitize_title_with_dashes("One&Two Test;", '', 'save'));
    5036    }
    5137
  • branches/4.0/tests/phpunit/tests/formatting/SanitizeUser.php

    r25002 r45013  
    1010        $this->assertEquals($expected, sanitize_user($input));
    1111    }
    12     /**
    13      * @ticket 10823
    14      */
    15     function test_strips_entities() {
    16         $this->assertEquals("ATT", sanitize_user("AT&amp;T"));
    17         $this->assertEquals("ATT Test;", sanitize_user("AT&amp;T Test;"));
    18         $this->assertEquals("AT&T Test;", sanitize_user("AT&T Test;"));
    19     }
    2012    function test_strips_percent_encoded_octets() {
    2113        $expected = is_multisite() ? 'franois' : 'Franois';
  • branches/4.0/tests/phpunit/tests/functions.php

    r29342 r45013  
    130130        $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' );
    131131        $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' );
    132     }
    133 
    134     /**
    135      * @ticket 9930
    136      */
    137     function test_is_serialized() {
    138         $cases = array(
    139             serialize(null),
    140             serialize(true),
    141             serialize(false),
    142             serialize(-25),
    143             serialize(25),
    144             serialize(1.1),
    145             serialize(2.1E+200),
    146             serialize('this string will be serialized'),
    147             serialize("a\nb"),
    148             serialize(array()),
    149             serialize(array(1,1,2,3,5,8,13)),
    150             serialize( (object)array('test' => true, '3', 4) )
    151         );
    152         foreach ( $cases as $case )
    153             $this->assertTrue( is_serialized($case), "Serialized data: $case" );
    154 
    155         $not_serialized = array(
    156             'a string',
    157             'garbage:a:0:garbage;',
    158             'b:4;',
    159             's:4:test;'
    160         );
    161         foreach ( $not_serialized as $case )
    162             $this->assertFalse( is_serialized($case), "Test data: $case" );
    163132    }
    164133
  • branches/4.0/tests/phpunit/tests/mail.php

    r32148 r45013  
    7070        $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'boundary="----=_Part_4892_25692638.1192452070893"') > 0);
    7171        $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset=') > 0);
    72     }
    73 
    74     /**
    75      * @ticket 15448
    76      */
    77     function test_wp_mail_plain_and_html() {
    78         $to = 'user@example.com';
    79         $subject = 'Test email with plain text and html versions';
    80         $messages = array( 'text/plain' => 'Here is some plain text.',
    81                        'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' );
    82 
    83         wp_mail( $to, $subject, $messages );
    84 
    85         preg_match( '/boundary="(.*)"/', $GLOBALS['phpmailer']->mock_sent[0]['header'], $matches);
    86         $boundry = $matches[1];
    87         $body = '--' . $boundry . '
    88 Content-Type: text/plain; charset = "UTF-8"
    89 Content-Transfer-Encoding: 8bit
    90 
    91 Here is some plain text.
    92 
    93 
    94 --' . $boundry . '
    95 Content-Type: text/html; charset = "UTF-8"
    96 Content-Transfer-Encoding: 8bit
    97 
    98 <html><head></head><body>Here is the HTML ;-)<body></html>
    99 
    100 
    101 
    102 --' . $boundry . '--
    103 ';
    104         // We need some better assertions here but these test the behaviour for now.
    105         $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']);
    10672    }
    10773
  • branches/4.0/tests/phpunit/tests/post.php

    r40456 r45013  
    741741
    742742    /**
    743      * @ticket 19373
    744      */
    745     function test_insert_programmatic_without_current_user_success() {
    746         $this->_unset_current_user();
    747 
    748         register_taxonomy( 'test_tax', 'post' );
    749 
    750         $title = rand_str();
    751         $post_data = array(
    752             'post_author' => $this->author_id,
    753             'post_status' => 'public',
    754             'post_content' => rand_str(),
    755             'post_title' => $title,
    756             'tax_input' => array(
    757                 'test_tax' => array( 'term', 'term2', 'term3' )
    758             )
    759         );
    760         // with sanitize set to false
    761         $insert_post_id = wp_insert_post( $post_data, true, false );
    762 
    763         $post = get_post( $insert_post_id );
    764         $this->assertEquals( $post->post_author, $this->author_id );
    765         $this->assertEquals( $post->post_title, $title );
    766 
    767         $terms = wp_get_object_terms( $insert_post_id, 'test_tax' );
    768         $this->assertTrue( ( is_array( $terms ) && count( $terms ) == 3 ) );
    769     }
    770 
    771     /**
    772      * @ticket 19373
    773      */
    774     function test_insert_programmatic_without_current_user_fail() {
    775         $this->_unset_current_user();
    776 
    777         register_taxonomy( 'test_tax', 'post' );
    778 
    779         $title = rand_str();
    780         $post_data = array(
    781             // post_author not set
    782             'post_status' => 'public',
    783             'post_content' => rand_str(),
    784             'post_title' => $title,
    785             'tax_input' => array(
    786                 'test_tax' => array( 'term', 'term2', 'term3' )
    787             )
    788         );
    789         // with sanitize set to false
    790         $insert_post_id = wp_insert_post( $post_data, true, false );
    791 
    792         // should error because no default user exists and no post author is passed in
    793         $this->assertInstanceOf( 'WP_Error', $insert_post_id );
    794         $this->assertEquals( 'empty_author', $insert_post_id->get_error_code() );
    795     }
    796 
    797     /**
    798743     * @ticket 24803
    799744     */
  • branches/4.0/tests/phpunit/tests/post/filtering.php

    r25002 r45013  
    9191    }
    9292
    93     /**
    94      * make sure unbalanced tags are fixed when they span a --more-- tag
    95      * @ticket 6297
    96      */
    97     function test_post_content_unbalanced_more() {
    98         $content = <<<EOF
    99 <em>some text<!--more-->
    100 that's continued after the jump</em>
    101 EOF;
    102 
    103         $expected = <<<EOF
    104 <em>some text</em><!--more-->
    105 that's continued after the jump
    106 EOF;
    107 
    108         $id = $this->factory->post->create( array( 'post_content' => $content ) );
    109         $post = get_post($id);
    110 
    111         $this->assertEquals( $expected, $post->post_content );
    112     }
    113 
    114     /**
    115      * make sure unbalanced tags are fixed when they span a --nextpage-- tag
    116      * @ticket 6297
    117      */
    118     function test_post_content_unbalanced_nextpage() {
    119         $content = <<<EOF
    120 <em>some text<!--nextpage-->
    121 that's continued after the jump</em>
    122 EOF;
    123 
    124         $expected = <<<EOF
    125 <em>some text</em><!--nextpage-->
    126 that's continued after the jump
    127 EOF;
    128 
    129         $id = $this->factory->post->create( array( 'post_content' => $content ) );
    130         $post = get_post($id);
    131 
    132         $this->assertEquals( $expected, $post->post_content );
    133     }
    134 
    135     /**
    136      * make sure unbalanced tags are fixed when they span both --more-- and --nextpage-- tags (in that order)
    137      * @ticket 6297
    138      */
    139     function test_post_content_unbalanced_more_nextpage() {
    140         $content = <<<EOF
    141 <em>some text<!--more-->
    142 that's continued after the jump</em>
    143 <!--nextpage-->
    144 <p>and the next page
    145 <!--nextpage-->
    146 breaks the graf</p>
    147 EOF;
    148 
    149         $expected = <<<EOF
    150 <em>some text</em><!--more-->
    151 that's continued after the jump
    152 <!--nextpage-->
    153 <p>and the next page
    154 </p><!--nextpage-->
    155 breaks the graf
    156 EOF;
    157 
    158         $id = $this->factory->post->create( array( 'post_content' => $content ) );
    159         $post = get_post($id);
    160 
    161         $this->assertEquals( $expected, $post->post_content );
    162     }
    163 
    164     /**
    165      * make sure unbalanced tags are fixed when they span both --nextpage-- and --more-- tags (in that order)
    166      * @ticket 6297
    167      */
    168     function test_post_content_unbalanced_nextpage_more() {
    169         $content = <<<EOF
    170 <em>some text<!--nextpage-->
    171 that's continued after the jump</em>
    172 <!--more-->
    173 <p>and the next page
    174 <!--nextpage-->
    175 breaks the graf</p>
    176 EOF;
    177 
    178         $expected = <<<EOF
    179 <em>some text</em><!--nextpage-->
    180 that's continued after the jump
    181 <!--more-->
    182 <p>and the next page
    183 </p><!--nextpage-->
    184 breaks the graf
    185 EOF;
    186 
    187         $id = $this->factory->post->create( array( 'post_content' => $content ) );
    188         $post = get_post($id);
    189 
    190         $this->assertEquals( $expected, $post->post_content );
    191     }
    192 
    19393    // make sure unbalanced tags are untouched when the balance option is off
    19494    function test_post_content_nobalance_nextpage_more() {
  • branches/4.0/tests/phpunit/tests/post/listPages.php

    r28400 r45013  
    344344    }
    345345
    346     /**
    347      * @ticket 27326
    348      */
    349     function test_wp_list_page_combo_exclude_depth() {
    350         $args = array(
    351             'echo'      => false,
    352             'exclude'   => '3',
    353             'depth'     => 3
    354         );
    355         $expected['exclude_depth'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
    356 <ul class=\'children\'>
    357     <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
    358     <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
    359     <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
    360 </ul>
    361 </li>
    362 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a>
    363 <ul class=\'children\'>
    364     <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
    365     <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
    366     <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
    367 </ul>
    368 </li>
    369 <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li>
    370 <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li>
    371 <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li>
    372 </ul></li>';
    373         $actual = wp_list_pages( $args );
    374         $this->AssertEquals( $expected['exclude_depth'], $actual );
    375     }
    376 
    377346}
  • branches/4.0/tests/phpunit/tests/query/results.php

    r30260 r45013  
    280280
    281281    /**
    282      * @ticket 18897
    283      */
    284     function test_query_offset_and_paged() {
    285         $posts = $this->q->query('paged=2&offset=3');
    286 
    287         $expected = array (
    288             0 => 'many-trackbacks',
    289             1 => 'one-trackback',
    290             2 => 'comment-test',
    291             3 => 'lorem-ipsum',
    292             4 => 'cat-c',
    293             5 => 'cat-b',
    294             6 => 'cat-a',
    295             7 => 'cats-a-and-c',
    296             8 => 'cats-b-and-c',
    297             9 => 'cats-a-and-b',
    298         );
    299 
    300         $this->assertCount( 10, $posts );
    301         $this->assertTrue( $this->q->is_paged() );
    302         $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
    303     }
    304 
    305     /**
    306282     * @ticket 11056
    307283     */
  • branches/4.0/tests/phpunit/tests/shortcode.php

    r33565 r45013  
    309309
    310310    /**
    311      * @ticket 14050
    312      */
    313     function test_multiple_shortcode_unautop() {
    314         // a blank line is added at the end, so test with it already there
    315         $test_string = "[footag]\n[footag]\n";
    316         $actual = shortcode_unautop( wpautop( $test_string ) );
    317         $this->assertEquals( $test_string, $actual );
    318     }
    319 
    320     /**
    321311     * @ticket 10326
    322312     */
  • branches/4.0/tests/phpunit/tests/taxonomy.php

    r28926 r45013  
    3434    }
    3535
    36     function test_get_the_taxonomies() {
    37         $post_id = $this->factory->post->create();
    38 
    39         $taxes = get_the_taxonomies( $post_id );
    40         $this->assertNotEmpty( $taxes );
    41         $this->assertEquals( array( 'category' ), array_keys( $taxes ) );
    42 
    43         $id = $this->factory->tag->create();
    44         wp_set_post_tags( $post_id, array( $id ) );
    45 
    46         $taxes = get_the_taxonomies( $post_id );
    47         $this->assertNotEmpty( $taxes );
    48         $this->assertCount( 2, $taxes );
    49         $this->assertEquals( array( 'category', 'post_tag' ), array_keys( $taxes ) );
    50     }
    51 
    5236    function test_the_taxonomies() {
    5337        $post_id = $this->factory->post->create();
     
    135119    }
    136120
    137     /**
    138      * @ticket 11058
    139      */
    140     function test_registering_taxonomies_to_object_types() {
    141         // Create a taxonomy to test with
    142         $tax = 'test_tax';
    143         $this->assertFalse( taxonomy_exists($tax) );
    144         register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    145 
    146         // Create a post type to test with
    147         $post_type = 'test_cpt';
    148         $this->assertFalse( get_post_type( $post_type ) );
    149         $this->assertObjectHasAttribute( 'name', register_post_type( $post_type ) );
    150 
    151         // Core taxonomy, core post type
    152         $this->assertTrue( unregister_taxonomy_for_object_type( 'category', 'post' ) );
    153         $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'post' ) );
    154         $this->assertTrue( register_taxonomy_for_object_type( 'category', 'post' ) );
    155 
    156         // Core taxonomy, non-core post type
    157         $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) );
    158         $this->assertTrue( unregister_taxonomy_for_object_type( 'category', $post_type ) );
    159         $this->assertFalse( unregister_taxonomy_for_object_type( 'category', $post_type ) );
    160         $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) );
    161 
    162         // Core taxonomies, non-post object types
    163         $this->assertFalse( register_taxonomy_for_object_type( 'category', 'user' ) );
    164         $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'user' ) );
    165 
    166         // Non-core taxonomy, core post type
    167         $this->assertTrue( unregister_taxonomy_for_object_type( $tax, 'post' ) );
    168         $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'post' ) );
    169         $this->assertTrue( register_taxonomy_for_object_type( $tax, 'post' ) );
    170 
    171         // Non-core taxonomy, non-core post type
    172         $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) );
    173         $this->assertTrue( unregister_taxonomy_for_object_type( $tax, $post_type ) );
    174         $this->assertFalse( unregister_taxonomy_for_object_type( $tax, $post_type ) );
    175         $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) );
    176 
    177         // Non-core taxonomies, non-post object types
    178         $this->assertFalse( register_taxonomy_for_object_type( $tax, 'user' ) );
    179         $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) );
    180 
    181         unset($GLOBALS['wp_taxonomies'][$tax]);
    182         _unregister_post_type( $post_type );
    183 
    184     }
    185121    /**
    186122     * @ticket 25706
  • branches/4.0/tests/phpunit/tests/xmlrpc/wp/uploadFile.php

    r30288 r45013  
    3030    }
    3131
    32     /**
    33      * @ticket 21292
    34      */
    35     function test_network_limit() {
    36         $this->make_user_by_role( 'editor' );
    37 
    38         update_option( 'blog_upload_space', 0.1 );
    39 
    40         // create attachment
    41         $filename = ( DIR_TESTDATA . '/images/canola.jpg' );
    42         $contents = file_get_contents( $filename );
    43         $data = array(
    44             'name' => 'canola.jpg',
    45             'type' => 'image/jpeg',
    46             'bits' => $contents
    47         );
    48 
    49         $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) );
    50 
    51         // Only multisite should have a limit
    52         if ( is_multisite() )
    53             $this->assertInstanceOf( 'IXR_Error', $result );
    54         else
    55             $this->assertNotInstanceOf( 'IXR_Error', $result );
    56     }
    57 
    5832}
Note: See TracChangeset for help on using the changeset viewer.