Changeset 45013 for branches/4.0
- Timestamp:
- 03/26/2019 12:45:57 AM (6 years ago)
- Location:
- branches/4.0
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
- Property svn:mergeinfo changed
/trunk merged: 29860,29869,29954,30160,30530
- Property svn:mergeinfo changed
-
branches/4.0/package.json
r44886 r45013 26 26 "grunt-legacy-util": "^0.2.0", 27 27 "grunt-patch-wordpress": "~0.2.1", 28 "grunt-sass": "~0.1 4.0",28 "grunt-sass": "~0.16.0", 29 29 "matchdep": "~0.3.0" 30 30 } -
branches/4.0/phpunit.xml.dist
r25165 r45013 26 26 <log type="junit" target="tests/phpunit/build/logs/junit.xml" logIncompleteSkipped="false"/> 27 27 </logging> 28 <php> 29 <const name="WP_RUN_CORE_TESTS" value="1" /> 30 </php> 28 31 </phpunit> -
branches/4.0/tests/phpunit/includes/testcase.php
r42065 r45013 38 38 $this->factory = new WP_UnitTest_Factory; 39 39 $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 40 52 $this->start_transaction(); 41 53 $this->expectDeprecated(); 42 54 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(); 43 83 } 44 84 -
branches/4.0/tests/phpunit/multisite.xml
r25294 r45013 26 26 </exclude> 27 27 </groups> 28 <php> 29 <const name="WP_RUN_CORE_TESTS" value="1" /> 30 </php> 28 31 </phpunit> -
branches/4.0/tests/phpunit/tests/canonical/https.php
r28713 r45013 45 45 * @ticket 27954 46 46 */ 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 2795461 */62 47 public function test_https_request_with_https_home() { 63 48 -
branches/4.0/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php
r25002 r45013 34 34 function test_handles_non_entity_ampersands() { 35 35 $this->assertEquals("penn-teller-bull", sanitize_title_with_dashes("penn & teller bull")); 36 }37 38 /**39 * @ticket 1082340 */41 function test_strips_entities() {42 $this->assertEquals("no-entities-here", sanitize_title_with_dashes("No Entities – Here &"));43 $this->assertEquals("one-two", sanitize_title_with_dashes("One & Two", '', 'save'));44 $this->assertEquals("one-two", sanitize_title_with_dashes("One { 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 && 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'));50 36 } 51 37 -
branches/4.0/tests/phpunit/tests/formatting/SanitizeUser.php
r25002 r45013 10 10 $this->assertEquals($expected, sanitize_user($input)); 11 11 } 12 /**13 * @ticket 1082314 */15 function test_strips_entities() {16 $this->assertEquals("ATT", sanitize_user("AT&T"));17 $this->assertEquals("ATT Test;", sanitize_user("AT&T Test;"));18 $this->assertEquals("AT&T Test;", sanitize_user("AT&T Test;"));19 }20 12 function test_strips_percent_encoded_octets() { 21 13 $expected = is_multisite() ? 'franois' : 'Franois'; -
branches/4.0/tests/phpunit/tests/functions.php
r29342 r45013 130 130 $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' ); 131 131 $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' ); 132 }133 134 /**135 * @ticket 9930136 */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" );163 132 } 164 133 -
branches/4.0/tests/phpunit/tests/mail.php
r32148 r45013 70 70 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'boundary="----=_Part_4892_25692638.1192452070893"') > 0); 71 71 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset=') > 0); 72 }73 74 /**75 * @ticket 1544876 */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: 8bit90 91 Here is some plain text.92 93 94 --' . $boundry . '95 Content-Type: text/html; charset = "UTF-8"96 Content-Transfer-Encoding: 8bit97 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']);106 72 } 107 73 -
branches/4.0/tests/phpunit/tests/post.php
r40456 r45013 741 741 742 742 /** 743 * @ticket 19373744 */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 false761 $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 19373773 */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 set782 '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 false790 $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 in793 $this->assertInstanceOf( 'WP_Error', $insert_post_id );794 $this->assertEquals( 'empty_author', $insert_post_id->get_error_code() );795 }796 797 /**798 743 * @ticket 24803 799 744 */ -
branches/4.0/tests/phpunit/tests/post/filtering.php
r25002 r45013 91 91 } 92 92 93 /**94 * make sure unbalanced tags are fixed when they span a --more-- tag95 * @ticket 629796 */97 function test_post_content_unbalanced_more() {98 $content = <<<EOF99 <em>some text<!--more-->100 that's continued after the jump</em>101 EOF;102 103 $expected = <<<EOF104 <em>some text</em><!--more-->105 that's continued after the jump106 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-- tag116 * @ticket 6297117 */118 function test_post_content_unbalanced_nextpage() {119 $content = <<<EOF120 <em>some text<!--nextpage-->121 that's continued after the jump</em>122 EOF;123 124 $expected = <<<EOF125 <em>some text</em><!--nextpage-->126 that's continued after the jump127 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 6297138 */139 function test_post_content_unbalanced_more_nextpage() {140 $content = <<<EOF141 <em>some text<!--more-->142 that's continued after the jump</em>143 <!--nextpage-->144 <p>and the next page145 <!--nextpage-->146 breaks the graf</p>147 EOF;148 149 $expected = <<<EOF150 <em>some text</em><!--more-->151 that's continued after the jump152 <!--nextpage-->153 <p>and the next page154 </p><!--nextpage-->155 breaks the graf156 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 6297167 */168 function test_post_content_unbalanced_nextpage_more() {169 $content = <<<EOF170 <em>some text<!--nextpage-->171 that's continued after the jump</em>172 <!--more-->173 <p>and the next page174 <!--nextpage-->175 breaks the graf</p>176 EOF;177 178 $expected = <<<EOF179 <em>some text</em><!--nextpage-->180 that's continued after the jump181 <!--more-->182 <p>and the next page183 </p><!--nextpage-->184 breaks the graf185 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 193 93 // make sure unbalanced tags are untouched when the balance option is off 194 94 function test_post_content_nobalance_nextpage_more() { -
branches/4.0/tests/phpunit/tests/post/listPages.php
r28400 r45013 344 344 } 345 345 346 /**347 * @ticket 27326348 */349 function test_wp_list_page_combo_exclude_depth() {350 $args = array(351 'echo' => false,352 'exclude' => '3',353 'depth' => 3354 );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 377 346 } -
branches/4.0/tests/phpunit/tests/query/results.php
r30260 r45013 280 280 281 281 /** 282 * @ticket 18897283 */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 /**306 282 * @ticket 11056 307 283 */ -
branches/4.0/tests/phpunit/tests/shortcode.php
r33565 r45013 309 309 310 310 /** 311 * @ticket 14050312 */313 function test_multiple_shortcode_unautop() {314 // a blank line is added at the end, so test with it already there315 $test_string = "[footag]\n[footag]\n";316 $actual = shortcode_unautop( wpautop( $test_string ) );317 $this->assertEquals( $test_string, $actual );318 }319 320 /**321 311 * @ticket 10326 322 312 */ -
branches/4.0/tests/phpunit/tests/taxonomy.php
r28926 r45013 34 34 } 35 35 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 52 36 function test_the_taxonomies() { 53 37 $post_id = $this->factory->post->create(); … … 135 119 } 136 120 137 /**138 * @ticket 11058139 */140 function test_registering_taxonomies_to_object_types() {141 // Create a taxonomy to test with142 $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 with147 $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 type152 $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 type157 $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 types163 $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 type167 $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 type172 $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 types178 $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 }185 121 /** 186 122 * @ticket 25706 -
branches/4.0/tests/phpunit/tests/xmlrpc/wp/uploadFile.php
r30288 r45013 30 30 } 31 31 32 /**33 * @ticket 2129234 */35 function test_network_limit() {36 $this->make_user_by_role( 'editor' );37 38 update_option( 'blog_upload_space', 0.1 );39 40 // create attachment41 $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' => $contents47 );48 49 $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) );50 51 // Only multisite should have a limit52 if ( is_multisite() )53 $this->assertInstanceOf( 'IXR_Error', $result );54 else55 $this->assertNotInstanceOf( 'IXR_Error', $result );56 }57 58 32 }
Note: See TracChangeset
for help on using the changeset viewer.