Ticket #7: trash.mu.stuff.2.diff
| File trash.mu.stuff.2.diff, 8.3 KB (added by duck_, 2 years ago) |
|---|
-
wp-testcase/test_admin_includes_theme.php
24 24 } 25 25 26 26 function test_page_templates() { 27 $this->knownWPBug(10959);28 27 $themes = get_themes(); 29 28 30 29 $theme = $themes['Page Template Theme']; -
wp-testcase/test_includes_theme.php
13 13 function test_get_themes_default() { 14 14 $themes = get_themes(); 15 15 16 // two themes are included by default: Classic and Default 17 $this->assertTrue(is_array($themes['WordPress Classic'])); 18 if (TEST_MU) { 19 $this->assertTrue(is_array($themes['WordPress mu Default'])); 20 $this->assertTrue(is_array($themes['WordPress mu Default/home'])); 21 } 22 else 23 $this->assertTrue(is_array($themes['WordPress Default'])); 16 // Twenty Ten is the default theme 17 $this->assertTrue(is_array($themes['Twenty Ten'])); 24 18 } 25 19 26 20 function test_get_themes_contents() { -
wp-test.php
1 1 <?php 2 2 /** 3 3 * wp-test.php 4 * 4 * 5 5 * WordPress Testrunner 6 * 6 * 7 7 * Example: 8 * 8 * 9 9 * # php wp-test.php -l 10 * 10 * 11 11 */ 12 12 13 13 // parse options 14 14 $options = 'v:t:r:sfln'; 15 if ( is_callable('getopt')) {16 $opts = getopt( $options);17 } else { 15 if ( is_callable('getopt') ) { 16 $opts = getopt( $options ); 17 } else { 18 18 include( dirname(__FILE__) . '/wp-testlib/getopt.php' ); 19 $opts = getoptParser::getopt( $options);19 $opts = getoptParser::getopt( $options ); 20 20 } 21 21 22 define('DIR_TESTROOT', realpath(dirname(__FILE__))); 23 if (!defined('DIR_TESTCASE')) { 24 define('DIR_TESTCASE', './wp-testcase'); 25 } 26 if (!defined('DIR_TESTDATA')) 27 define('DIR_TESTDATA', './wp-testdata'); 28 define('TEST_WP', true); 29 define('TEST_MU', (@$opts['v'] == 'mu')); 30 define('TEST_SKIP_KNOWN_BUGS', array_key_exists('s', $opts)); 31 define('TEST_FORCE_KNOWN_BUGS', array_key_exists('f', $opts)); 32 #define('SAVEQUERIES', true); 22 define( 'DIR_TESTROOT', realpath(dirname(__FILE__)) ); 33 23 34 if (!empty($opts['r'])) 35 define('DIR_WP', realpath($opts['r'])); 24 if ( ! defined('DIR_TESTCASE') ) 25 define( 'DIR_TESTCASE', './wp-testcase' ); 26 27 if ( ! defined('DIR_TESTDATA') ) 28 define( 'DIR_TESTDATA', './wp-testdata' ); 29 30 define( 'TEST_SKIP_KNOWN_BUGS', array_key_exists('s', $opts) ); 31 define( 'TEST_FORCE_KNOWN_BUGS', array_key_exists('f', $opts) ); 32 // define('SAVEQUERIES', true); 33 34 if ( ! empty($opts['r']) ) 35 define( 'DIR_WP', realpath($opts['r']) ); 36 36 else 37 if ( !empty($opts['v']))38 define( 'DIR_WP', DIR_TESTROOT.'/wordpress-'.$opts['v']);37 if ( ! empty($opts['v']) ) 38 define( 'DIR_WP', DIR_TESTROOT.'/wordpress-'.$opts['v'] ); 39 39 else 40 define( 'DIR_WP', DIR_TESTROOT.'/wordpress');40 define( 'DIR_WP', DIR_TESTROOT.'/wordpress' ); 41 41 42 42 // make sure all useful errors are displayed during setup 43 error_reporting( E_ALL & ~E_DEPRECATED);44 ini_set( 'display_errors', true);43 error_reporting( E_ALL & ~E_DEPRECATED ); 44 ini_set( 'display_errors', true ); 45 45 46 require_once( DIR_TESTROOT.'/wp-testlib/base.php');47 require_once( DIR_TESTROOT.'/wp-testlib/utils.php');46 require_once( DIR_TESTROOT.'/wp-testlib/base.php' ); 47 require_once( DIR_TESTROOT.'/wp-testlib/utils.php' ); 48 48 49 49 // configure wp 50 50 51 require_once( DIR_TESTROOT.'/wp-config.php');52 define( 'ABSPATH', realpath(DIR_WP).'/');51 require_once( DIR_TESTROOT.'/wp-config.php' ); 52 define( 'ABSPATH', DIR_WP.'/' ); 53 53 54 if ( !defined('DIR_TESTPLUGINS'))55 define( 'DIR_TESTPLUGINS', './wp-plugins');54 if ( ! defined('DIR_TESTPLUGINS') ) 55 define( 'DIR_TESTPLUGINS', DIR_TESTROOT.'/wp-plugins' ); 56 56 57 57 // override stuff 58 59 require_once(DIR_TESTROOT.'/wp-testlib/mock-mailer.php'); 58 require_once( DIR_TESTROOT.'/wp-testlib/mock-mailer.php' ); 60 59 $GLOBALS['phpmailer'] = new MockPHPMailer(); 61 60 62 61 // install wp 63 define( 'WP_BLOG_TITLE', rand_str());64 define( 'WP_USER_NAME', rand_str());65 define( 'WP_USER_EMAIL', rand_str().'@example.com');62 define( 'WP_BLOG_TITLE', rand_str() ); 63 define( 'WP_USER_NAME', rand_str() ); 64 define( 'WP_USER_EMAIL', rand_str().'@example.com' ); 66 65 67 68 66 // initialize wp 69 define( 'WP_INSTALLING', 1);67 define( 'WP_INSTALLING', 1 ); 70 68 $_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // prevent a warning from some sloppy code in wp-settings.php 71 require_once( ABSPATH.'wp-settings.php');69 require_once( ABSPATH.'wp-settings.php' ); 72 70 73 71 // Allow tests to override wp_die 74 72 add_filter( 'wp_die_handler', '_wp_die_handler_filter' ); 75 73 76 74 drop_tables(); 77 75 78 if (TEST_MU)79 require_once(ABSPATH.'wp-admin/upgrade-functions.php');80 else81 require_once(ABSPATH.'wp-admin/includes/upgrade.php');82 wp_install(WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true);83 76 84 if (TEST_MU) { 85 // wp-settings.php would normally init this stuff, but that doesn't work because we've 86 // only just installed 87 $GLOBALS['blog_id'] = 1; 88 $GLOBALS['wpdb']->blogid = 1; 89 $GLOBALS['current_blog'] = $GLOBALS['wpdb']->get_results('SELECT * from wp_blogs where blog_id=1'); 90 } 77 require_once( ABSPATH.'wp-admin/includes/upgrade.php' ); 78 wp_install( WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true ); 91 79 92 80 // make sure we're installed 93 assert( true == is_blog_installed());81 assert( is_blog_installed() ); 94 82 95 83 // include plugins for testing, if any 96 if ( is_dir(DIR_TESTPLUGINS)) {84 if ( is_dir(DIR_TESTPLUGINS) ) { 97 85 $plugins = glob(realpath(DIR_TESTPLUGINS).'/*.php'); 98 foreach ( $plugins as $plugin)86 foreach ( $plugins as $plugin ) 99 87 include_once($plugin); 100 88 } 101 89 102 90 // needed for jacob's tests 103 ini_set( 'include_path', ini_get('include_path') . PATH_SEPARATOR . ABSPATH . '/wp-includes');104 define( 'PHPUnit_MAIN_METHOD', false);91 ini_set( 'include_path', ini_get('include_path') . PATH_SEPARATOR . ABSPATH . '/wp-includes' ); 92 define( 'PHPUnit_MAIN_METHOD', false ); 105 93 $original_wpdb = $GLOBALS['wpdb']; 106 94 107 include_once( DIR_TESTDATA . '/sample_blogs.php');95 include_once( DIR_TESTDATA . '/sample_blogs.php' ); 108 96 // include all files in DIR_TESTCASE, and fetch all the WPTestCase descendents 109 $files = wptest_get_all_test_files( DIR_TESTCASE);110 foreach ( $files as $file) {97 $files = wptest_get_all_test_files( DIR_TESTCASE ); 98 foreach ( $files as $file ) 111 99 require_once($file); 112 }113 100 $classes = wptest_get_all_test_cases(); 114 101 115 102 // some of jacob's tests clobber the wpdb object, so restore it … … 119 106 wptest_listall_testcases($classes); 120 107 } else { 121 108 do_action('test_start'); 122 109 123 110 // hide warnings during testing, since that's the normal WP behaviour 124 if ( ! WP_DEBUG ) {125 error_reporting( E_ALL ^ E_NOTICE);126 } 111 if ( ! WP_DEBUG ) 112 error_reporting( E_ALL ^ E_NOTICE ); 113 127 114 // run the tests and print the results 128 list ($result, $printer) = wptest_run_tests($classes, @$opts['t']);129 wptest_print_result( $printer,$result);115 list( $result, $printer ) = wptest_run_tests( $classes, @$opts['t'] ); 116 wptest_print_result( $printer, $result ); 130 117 } 131 if ( ! isset($opts['n']) ) {118 if ( ! isset($opts['n']) ) { 132 119 // clean up the database 133 120 drop_tables(); 134 121 } -
wp-testlib/base.php
172 172 function _delete_all_posts() { 173 173 global $wpdb; 174 174 175 $ all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}");176 if ( $all_posts) {177 foreach ( $all_posts as $id)178 wp_delete_post( $id);175 $posts = $wpdb->get_col( "SELECT ID from {$wpdb->posts}" ); 176 if ( $posts ) { 177 foreach ( $posts as $id ) 178 wp_delete_post( $id, true ); 179 179 } 180 180 } 181 181 … … 421 421 } 422 422 423 423 /** 424 * Skips the current test if there is open WordPress MU ticket with id $ticket_id425 */426 function knownMUBug($ticket_id) {427 if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http://trac.mu.wordpress.org', $ticket_id))) {428 $this->markTestSkipped();429 }430 }431 432 /**433 424 * Skips the current test if there is open plugin ticket with id $ticket_id 434 425 */ 435 426 function knownPluginBug($ticket_id) { 436 if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http:// dev.wp-plugins.org', $ticket_id))) {427 if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http://plugins.trac.wordpress.org', $ticket_id))) { 437 428 $this->markTestSkipped(); 438 429 } 439 430 }
