Changeset 903 in tests
- Timestamp:
- 07/16/2012 05:24:25 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/exceptions.php
r883 r903 2 2 3 3 class WP_Tests_Exception extends PHPUnit_Framework_Exception { 4 4 5 5 } 6 6 -
trunk/includes/mock-mailer.php
r764 r903 2 2 3 3 require_once(ABSPATH . '/wp-includes/class-phpmailer.php'); 4 4 5 5 class MockPHPMailer extends PHPMailer { 6 6 var $mock_sent = array(); -
trunk/includes/testcase-ajax.php
r868 r903 16 16 */ 17 17 abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { 18 18 19 19 /** 20 20 * Last AJAX response. This is set via echo -or- wp_die. 21 * @var type 21 * @var type 22 22 */ 23 23 protected $_last_response = ''; … … 25 25 /** 26 26 * List of ajax actions called via POST 27 * @var type 27 * @var type 28 28 */ 29 29 protected $_core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed_cache' ); … … 37 37 /** 38 38 * List of ajax actions called via GET 39 * @var type 39 * @var type 40 40 */ 41 41 protected $_core_actions_post = array( … … 77 77 $this->factory->post->create_many( 5 ); 78 78 } 79 79 80 80 /** 81 81 * Tear down the test fixture. … … 124 124 * $this->setExpectedException( 'WPAjaxDieContinueException', 'something contained in $message' ); 125 125 * </code> 126 * @param string $message 126 * @param string $message 127 127 */ 128 128 public function dieHandler( $message ) { … … 143 143 * Switch between user roles 144 144 * E.g. administrator, editor, author, contributor, subscriber 145 * @param string $role 145 * @param string $role 146 146 */ 147 147 protected function _setRole( $role ) { … … 156 156 * Capture the output via output buffering, and if there is any, store 157 157 * it in $this->_last_message. 158 * @param string $action 158 * @param string $action 159 159 */ 160 160 protected function _handleAjax($action) { 161 161 162 162 // Start output buffering 163 163 ini_set( 'implicit_flush', false ); -
trunk/tests/test_admin_includes_misc.php
r796 r903 19 19 => 'wordpress.org/about/philosophy/#...', // shorten to 32 if > 35 after cleaning 20 20 ); 21 foreach ( $tests as $k => $v ) 21 foreach ( $tests as $k => $v ) 22 22 $this->assertEquals( $v, url_shorten( $k ) ); 23 23 } -
trunk/tests/test_admin_includes_screen.php
r877 r903 133 133 $screen = convert_to_screen( 'comments' ); 134 134 $this->assertEquals( $screen->base, 'post' ); 135 135 136 136 // Core wins. 137 137 $screen = convert_to_screen( 'edit-tags' ); -
trunk/tests/test_db.php
r894 r903 13 13 */ 14 14 protected $_queries = array(); 15 15 16 16 /** 17 17 * Set up the test fixture … … 52 52 // Save the current locale 53 53 $current_locale = setlocale( LC_ALL, NULL ); 54 54 55 55 // Switch to Russian 56 56 $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES' ); 57 57 if ( false === $flag ) 58 58 $this->markTestSkipped( 'No European languages available for testing' ); 59 59 60 60 // Try an update query 61 61 $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' ) 68 68 ); 69 69 $wpdb->suppress_errors( false ); 70 70 71 71 // Ensure the float isn't 0,700 72 72 $this->assertContains( '0.700', array_pop( $this->_queries ) ); -
trunk/tests/test_http.php
r894 r903 220 220 return; 221 221 } 222 222 223 223 $actual = WP_HTTP::make_absolute_url( $relative_url, $absolute_url ); 224 224 $this->assertEquals( $expected, $actual ); … … 230 230 array( 'http://site.com/', 'http://example.com/', 'http://site.com/' ), // Absolute URL provided 231 231 array( '/location', '', '/location' ), // No current url provided 232 232 233 233 array( '', 'http://example.com', 'http://example.com/' ), // No location provided 234 234 235 235 // Location provided relative to site root 236 236 array( '/root-relative-link.ext', 'http://example.com/', 'http://example.com/root-relative-link.ext' ), 237 237 array( '/root-relative-link.ext?with=query', 'http://example.com/index.ext?query', 'http://example.com/root-relative-link.ext?with=query' ), 238 238 239 239 // Location provided relative to current file/directory 240 240 array( 'relative-file.ext', 'http://example.com/', 'http://example.com/relative-file.ext' ), 241 241 array( 'relative-file.ext', 'http://example.com/filename', 'http://example.com/relative-file.ext' ), 242 242 array( 'relative-file.ext', 'http://example.com/directory/', 'http://example.com/directory/relative-file.ext' ), 243 243 244 244 // Location provided relative to current file/directory but in a parent directory 245 245 array( '../file-in-parent.ext', 'http://example.com', 'http://example.com/file-in-parent.ext' ), … … 254 254 array( '../../file-in-grand-parent.ext', 'http://example.com/directory/filename/', 'http://example.com/file-in-grand-parent.ext' ), 255 255 array( '../../file-in-grand-parent.ext', 'http://example.com/directory1/directory2/filename', 'http://example.com/file-in-grand-parent.ext' ), 256 256 257 257 // Query strings should attach, or replace existing query string. 258 258 array( '?query=string', 'http://example.com', 'http://example.com/?query=string' ), … … 260 260 array( '?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/file.ext?query=string' ), 261 261 array( 'otherfile.ext?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/otherfile.ext?query=string' ), 262 262 263 263 // A file with a leading dot 264 264 array( '.ext', 'http://example.com/', 'http://example.com/.ext' ) -
trunk/tests/test_image.php
r894 r903 125 125 function test_utf8_iptc_tags() { 126 126 127 // trilingual UTF-8 text in the ITPC caption-abstract field 127 // trilingual UTF-8 text in the ITPC caption-abstract field 128 128 $out = wp_read_image_metadata(DIR_TESTDATA.'/images/test-image-iptc.jpg'); 129 129 130 130 $this->assertEquals('This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $out['caption']); 131 131 } 132 132 133 133 /** 134 134 * wp_read_image_metadata() should false if the image file doesn't exist -
trunk/tests/test_includes_balance_tags.php
r894 r903 28 28 } 29 29 } 30 30 31 31 /** 32 32 * If a recognized valid single tag appears unclosed, it should get self-closed -
trunk/tests/test_includes_canonical.php
r894 r903 36 36 // Already created by install defaults: 37 37 // $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); 38 38 39 39 $this->term_ids = array(); 40 40 … … 53 53 54 54 $this->factory->post->create( array( 'post_date' => '2008-09-05 00:00:00' ) ); 55 55 56 56 $this->factory->post->create( array( 'import_id' => 123 ) ); 57 57 $this->factory->post->create( array( 'import_id' => 1 ) ); 58 58 $this->factory->post->create( array( 'import_id' => 358 ) ); 59 59 60 60 $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'sample-page' ) ); 61 61 $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); … … 75 75 $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-a' ) ); 76 76 $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-b' ) ); 77 77 78 78 $this->factory->term->create( array( 'name' => 'post-formats' ) ); 79 79 } … … 106 106 107 107 $ticket_ref = ($ticket > 0) ? 'Ticket #' . $ticket : null; 108 108 109 109 if ( is_string($expected) ) 110 110 $expected = array('url' => $expected); … … 360 360 * (string) expected redirect location 361 361 * [3]: (optional) The ticket the test refers to, Can be skipped if unknown. 362 */ 362 */ 363 363 return array( 364 364 array( '/?p=123', '/?p=123' ), -
trunk/tests/test_includes_class-wp-xmlrpc-server.php
r877 r903 11 11 $myxmlrpcserver = new wp_xmlrpc_server(); 12 12 $result = $myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); 13 13 14 14 $this->assertInstanceOf( 'IXR_Error', $result ); 15 15 $this->assertEquals( 405, $result->code ); -
trunk/tests/test_includes_formatting.php
r894 r903 170 170 'In his famous speech “You and Your research” (here: 171 171 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', 173 173 ); 174 174 $urls_expected = array( … … 184 184 'In his famous speech “You and Your research” (here: 185 185 <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', 187 187 ); 188 188 foreach ($urls_before as $key => $url) { … … 754 754 * 755 755 * @ticket 19855 756 */ 756 */ 757 757 public function test_skip_pre_elements() { 758 758 $code = file_get_contents( DIR_TESTDATA . '/formatting/sizzle.js' ); 759 759 $code = str_replace( "\r", '', $code ); 760 760 $code = htmlentities( $code ); 761 761 762 762 // Not wrapped in <p> tags 763 763 $str = "<pre>$code</pre>"; … … 766 766 // Text before/after is wrapped in <p> tags 767 767 $str = "Look at this code\n\n<pre>$code</pre>\n\nIsn't that cool?"; 768 768 769 769 // Expected text after wpautop 770 770 $expected = '<p>Look at this code</p>' . "\n<pre>" . $code . "</pre>\n" . '<p>Isn\'t that cool?</p>'; … … 776 776 $this->assertEquals( $expected, trim( wpautop( $str ) ) ); 777 777 } 778 778 779 779 /** 780 780 * wpautop() Should not add <br/> to "<input>" elements 781 781 * 782 782 * @ticket 16456 783 */ 783 */ 784 784 public function test_skip_input_elements() { 785 785 $str = 'Username: <input type="text" id="username" name="username" /><br />Password: <input type="password" id="password1" name="password1" />'; … … 1458 1458 1459 1459 $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 ) ); 1461 1461 } 1462 1462 … … 1526 1526 // acute accent 1527 1527 $this->assertEquals( 'AaAaEeOoOoUu', remove_accents( 'ẤấẮắẾếỐốỚớỨứ' ) ); 1528 // dot below 1528 // dot below 1529 1529 $this->assertEquals( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẠạẬậẶặẸẹỆệỊịỌọỘộỢợỤụỰựỴỵ' ) ); 1530 1530 } -
trunk/tests/test_includes_functions.php
r894 r903 462 462 $this->assertEquals( $expected[ $header ], $value, $header ); 463 463 } 464 464 465 465 function test_get_file_data_cr_line_endings() { 466 466 $headers = array( 'SomeHeader' => 'Some Header', 'Description' => 'Description', 'Author' => 'Author' ); -
trunk/tests/test_includes_kses.php
r894 r903 20 20 'title' => 'title', 21 21 ); 22 22 23 23 foreach ( $attributes as $name => $value ) { 24 24 $string = "<address $name='$value'>1 WordPress Avenue, The Internet.</address>"; … … 44 44 'target' => '_blank', 45 45 ); 46 46 47 47 foreach ( $attributes as $name => $value ) { 48 48 $string = "<a $name='$value'>I link this</a>"; -
trunk/tests/test_includes_media.php
r883 r903 30 30 31 31 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 ) 34 34 ); 35 35 $this->assertEquals( 2, preg_match_all( '/wp-caption/', $result, $_r ) ); … … 40 40 41 41 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( 44 44 'width' => 20, 45 45 'caption' => $this->caption, … … 54 54 55 55 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 ) 58 58 ); 59 59 $our_preg = preg_quote( $this->html_content ); … … 63 63 64 64 function test_new_img_caption_shortcode_new_format() { 65 $result = img_caption_shortcode( 65 $result = img_caption_shortcode( 66 66 array( 'width' => 20 ), 67 67 $this->img_content . $this->html_content … … 76 76 function test_new_img_caption_shortcode_new_format_and_linked_image() { 77 77 $linked_image = "<a href='#'>{$this->img_content}</a>"; 78 $result = img_caption_shortcode( 78 $result = img_caption_shortcode( 79 79 array( 'width' => 20 ), 80 80 $linked_image . $this->html_content … … 89 89 function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { 90 90 $linked_image = "<a href='#'>{$this->img_content}</a>"; 91 $result = img_caption_shortcode( 91 $result = img_caption_shortcode( 92 92 array( 'width' => 20 ), 93 93 $linked_image . "\n\n" . $this->html_content -
trunk/tests/test_includes_post.php
r894 r903 476 476 function tearDown() { 477 477 // Remove all uploads. 478 $uploads = wp_upload_dir(); 478 $uploads = wp_upload_dir(); 479 479 foreach ( scandir( $uploads['basedir'] ) as $file ) 480 _rmdir( $uploads['basedir'] . '/' . $file ); 480 _rmdir( $uploads['basedir'] . '/' . $file ); 481 481 482 482 parent::tearDown(); -
trunk/tests/test_includes_wp-scripts.php
r896 r903 42 42 $this->assertEquals("", get_echo('wp_print_scripts')); 43 43 } 44 44 45 45 /** 46 46 * Test the different protocol references in wp_enqueue_script … … 63 63 wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 64 64 $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 66 66 // Try with an automatic protocol reference (//) 67 67 wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); … … 76 76 wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 77 77 $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 79 79 // Go! 80 80 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); -
trunk/tests/test_includes_wp-styles.php
r896 r903 35 35 $expected .= "<link rel='stylesheet' id='no-deps-null-version-css' href='http://example.com' type='text/css' media='all' />\n"; 36 36 $expected .= "<link rel='stylesheet' id='no-deps-null-version-print-media-css' href='http://example.com' type='text/css' media='print' />\n"; 37 37 38 38 $this->assertEquals($expected, get_echo('wp_print_styles')); 39 39 … … 41 41 $this->assertEquals("", get_echo('wp_print_styles')); 42 42 } 43 43 44 44 /** 45 45 * Test the different protocol references in wp_enqueue_style … … 62 62 wp_enqueue_style( 'reset-css-https', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); 63 63 $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 65 65 // Try with an automatic protocol reference (//) 66 66 wp_enqueue_style( 'reset-css-doubleslash', '//yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); -
trunk/tests/test_meta.php
r877 r903 75 75 $expected .= "foo bar\n"; 76 76 $expected .= "foo"; 77 77 78 78 $this->assertEquals($expected, strip_ws($in)); 79 79 -
trunk/tests/test_ms.php
r894 r903 32 32 33 33 // update the blog count cache to use get_blog_count() 34 wp_update_network_counts(); 34 wp_update_network_counts(); 35 35 $this->assertEquals( 4 + 1, (int) get_blog_count() ); 36 36 … … 53 53 54 54 // update the blog count cache to use get_blog_count() 55 wp_update_network_counts(); 55 wp_update_network_counts(); 56 56 $this->assertEquals( 1, get_blog_count() ); 57 57 } … … 153 153 activate_plugin($path, '', $network_wide = true); 154 154 $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 ); 156 156 157 157 //deactivate the plugin … … 189 189 190 190 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')); 192 192 193 193 // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set 194 194 wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); 195 195 196 $this->assertInternalType('int', wp_next_scheduled('update_network_counts')); 196 $this->assertInternalType('int', wp_next_scheduled('update_network_counts')); 197 197 } 198 198 … … 203 203 204 204 update_site_option('registration', 'all'); 205 $this->assertTrue( users_can_register_signup_filter() ); 205 $this->assertTrue( users_can_register_signup_filter() ); 206 206 207 207 update_site_option('registration', 'user'); … … 209 209 210 210 update_site_option('registration', 'none'); 211 $this->assertFalse( users_can_register_signup_filter() ); 211 $this->assertFalse( users_can_register_signup_filter() ); 212 212 } 213 213 … … 333 333 $this->assertEquals( 'example.com', $blog->domain ); 334 334 $this->assertEquals( 'my_path/', $blog->path ); 335 $this->assertEquals( '0', $blog->spam ); 335 $this->assertEquals( '0', $blog->spam ); 336 336 337 337 $result = update_blog_details( $blog_id, array('domain' => 'example2.com','spam' => 1) ); -
trunk/tests/test_option.php
r897 r903 14 14 15 15 function __return_foo() { 16 return 'foo'; 16 return 'foo'; 17 17 } 18 18 … … 86 86 class TestSiteOption extends WP_UnitTestCase { 87 87 function __return_foo() { 88 return 'foo'; 88 return 'foo'; 89 89 } 90 90 … … 169 169 170 170 $this->assertEquals( get_site_option( $option, $default ), $default ); 171 $this->assertFalse( get_site_option( $option ) ); 171 $this->assertFalse( get_site_option( $option ) ); 172 172 } 173 173 } -
trunk/tests/test_query.php
r894 r903 240 240 $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); 241 241 } 242 242 243 243 // FIXME: what is this for? 244 244 // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' -
trunk/tests/test_query_results.php
r894 r903 22 22 $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 ) ) ); 23 23 $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 ) ) ); 25 25 $this->factory->post->create( array( 'post_title' => 'cat-b', 'post_date' => '2009-05-01 00:00:00', 'post_category' => array( $cat_b ) ) ); 26 26 $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 39 39 'baz' => 'default baz', 40 40 ), $atts)); 41 41 42 42 return "foo = {$foo}"; 43 43 } -
trunk/tests/test_uploads.php
r901 r903 26 26 27 27 // Remove year/month folders created by wp_upload_dir(). 28 $uploads = wp_upload_dir(); 28 $uploads = wp_upload_dir(); 29 29 foreach ( scandir( $uploads['basedir'] ) as $file ) 30 _rmdir( $uploads['basedir'] . '/' . $file ); 30 _rmdir( $uploads['basedir'] . '/' . $file ); 31 31 _rmdir( ABSPATH . 'foo/' ); 32 32 } -
trunk/tests/test_user.php
r896 r903 160 160 } 161 161 } 162 162 163 163 /** 164 164 * Test the magic __unset method … … 188 188 $this->assertNotEmpty( $user->ID ); 189 189 unset( $user->ID ); 190 $this->assertEmpty( $user->ID ); 190 $this->assertEmpty( $user->ID ); 191 191 } 192 192
Note: See TracChangeset
for help on using the changeset viewer.