Ticket #7: trash.mu.stuff.diff

File trash.mu.stuff.diff, 8.3 KB (added by duck_, 3 years ago)
Line 
1Index: wp-test.php
2===================================================================
3--- wp-test.php (revision 320)
4+++ wp-test.php (working copy)
5@@ -1,115 +1,99 @@
6 <?php
7 /**
8  * wp-test.php
9- *
10+ *
11  * WordPress Testrunner
12- *
13+ *
14  * Example:
15- *
16+ *
17  * # php wp-test.php -l
18- *
19+ *
20  */
21 
22 // parse options
23-$options = 'v:t:r:sfln';
24-if (is_callable('getopt')) {
25-       $opts = getopt($options);
26-} else {       
27+$options = 't:r:sfln';
28+if ( is_callable('getopt') ) {
29+       $opts = getopt( $options );
30+} else {
31        include( dirname(__FILE__) . '/wp-testlib/getopt.php' );
32-       $opts = getoptParser::getopt($options);
33+       $opts = getoptParser::getopt( $options );
34 }
35 
36-define('DIR_TESTROOT', realpath(dirname(__FILE__)));
37-if (!defined('DIR_TESTCASE')) {
38-       define('DIR_TESTCASE', './wp-testcase');
39-}
40-if (!defined('DIR_TESTDATA'))
41-       define('DIR_TESTDATA', './wp-testdata');
42-define('TEST_WP', true);
43-define('TEST_MU', (@$opts['v'] == 'mu'));
44-define('TEST_SKIP_KNOWN_BUGS', array_key_exists('s', $opts));
45-define('TEST_FORCE_KNOWN_BUGS', array_key_exists('f', $opts));
46-#define('SAVEQUERIES', true);
47+define( 'DIR_TESTROOT', realpath(dirname(__FILE__)) );
48 
49-if (!empty($opts['r']))
50-       define('DIR_WP', realpath($opts['r']));
51+if ( ! defined('DIR_TESTCASE') )
52+       define( 'DIR_TESTCASE', './wp-testcase' );
53+
54+if ( ! defined('DIR_TESTDATA') )
55+       define( 'DIR_TESTDATA', './wp-testdata' );
56+
57+define( 'TEST_SKIP_KNOWN_BUGS', array_key_exists('s', $opts) );
58+define( 'TEST_FORCE_KNOWN_BUGS', array_key_exists('f', $opts) );
59+// define('SAVEQUERIES', true);
60+
61+if ( ! empty($opts['r']) )
62+       define( 'DIR_WP', realpath($opts['r']) );
63 else
64-       if (!empty($opts['v']))
65-               define('DIR_WP', DIR_TESTROOT.'/wordpress-'.$opts['v']);
66-       else
67-               define('DIR_WP', DIR_TESTROOT.'/wordpress');
68+       define( 'DIR_WP', DIR_TESTROOT.'/wordpress' );
69 
70 // make sure all useful errors are displayed during setup
71-error_reporting(E_ALL & ~E_DEPRECATED);
72-ini_set('display_errors', true);
73+error_reporting( E_ALL & ~E_DEPRECATED );
74+ini_set( 'display_errors', true );
75 
76-require_once(DIR_TESTROOT.'/wp-testlib/base.php');
77-require_once(DIR_TESTROOT.'/wp-testlib/utils.php');
78+require_once( DIR_TESTROOT.'/wp-testlib/base.php' );
79+require_once( DIR_TESTROOT.'/wp-testlib/utils.php' );
80 
81 // configure wp
82 
83-require_once(DIR_TESTROOT.'/wp-config.php');
84-define('ABSPATH', realpath(DIR_WP).'/');
85+require_once( DIR_TESTROOT.'/wp-config.php' );
86+define( 'ABSPATH', DIR_WP.'/' );
87 
88-if (!defined('DIR_TESTPLUGINS'))
89-       define('DIR_TESTPLUGINS', './wp-plugins');
90+if ( ! defined('DIR_TESTPLUGINS') )
91+       define( 'DIR_TESTPLUGINS', DIR_TESTROOT.'/wp-plugins' );
92 
93 // override stuff
94-
95-require_once(DIR_TESTROOT.'/wp-testlib/mock-mailer.php');
96+require_once( DIR_TESTROOT.'/wp-testlib/mock-mailer.php' );
97 $GLOBALS['phpmailer'] = new MockPHPMailer();
98 
99 // install wp
100-define('WP_BLOG_TITLE', rand_str());
101-define('WP_USER_NAME', rand_str());
102-define('WP_USER_EMAIL', rand_str().'@example.com');
103+define( 'WP_BLOG_TITLE', rand_str() );
104+define( 'WP_USER_NAME', rand_str() );
105+define( 'WP_USER_EMAIL', rand_str().'@example.com' );
106 
107-
108 // initialize wp
109-define('WP_INSTALLING', 1);
110+define( 'WP_INSTALLING', 1 );
111 $_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // prevent a warning from some sloppy code in wp-settings.php
112-require_once(ABSPATH.'wp-settings.php');
113+require_once( ABSPATH.'wp-settings.php' );
114 
115 // Allow tests to override wp_die
116 add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
117 
118 drop_tables();
119 
120-if (TEST_MU)
121-       require_once(ABSPATH.'wp-admin/upgrade-functions.php');
122-else
123-       require_once(ABSPATH.'wp-admin/includes/upgrade.php');
124-wp_install(WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true);
125 
126-if (TEST_MU) {
127-               // wp-settings.php would normally init this stuff, but that doesn't work because we've
128-               // only just installed
129-               $GLOBALS['blog_id'] = 1;
130-               $GLOBALS['wpdb']->blogid = 1;
131-               $GLOBALS['current_blog'] = $GLOBALS['wpdb']->get_results('SELECT * from wp_blogs where blog_id=1');
132-}
133+require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
134+wp_install( WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true );
135 
136 // make sure we're installed
137-assert(true == is_blog_installed());
138+assert( is_blog_installed() );
139 
140 // include plugins for testing, if any
141-if (is_dir(DIR_TESTPLUGINS)) {
142+if ( is_dir(DIR_TESTPLUGINS) ) {
143        $plugins = glob(realpath(DIR_TESTPLUGINS).'/*.php');
144-       foreach ($plugins as $plugin)
145+       foreach ( $plugins as $plugin )
146                include_once($plugin);
147 }
148 
149 // needed for jacob's tests
150-ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . ABSPATH . '/wp-includes');
151-define('PHPUnit_MAIN_METHOD', false);
152+ini_set( 'include_path', ini_get('include_path') . PATH_SEPARATOR . ABSPATH . '/wp-includes' );
153+define( 'PHPUnit_MAIN_METHOD', false );
154 $original_wpdb = $GLOBALS['wpdb'];
155 
156-include_once(DIR_TESTDATA . '/sample_blogs.php');
157+include_once( DIR_TESTDATA . '/sample_blogs.php' );
158 // include all files in DIR_TESTCASE, and fetch all the WPTestCase descendents
159-$files = wptest_get_all_test_files(DIR_TESTCASE);
160-foreach ($files as $file) {
161+$files = wptest_get_all_test_files( DIR_TESTCASE );
162+foreach ( $files as $file )
163        require_once($file);
164-}
165 $classes = wptest_get_all_test_cases();
166 
167 // some of jacob's tests clobber the wpdb object, so restore it
168@@ -119,16 +103,16 @@
169        wptest_listall_testcases($classes);
170 } else {
171        do_action('test_start');
172-       
173+
174        // hide warnings during testing, since that's the normal WP behaviour
175-       if ( !WP_DEBUG ) {
176-               error_reporting(E_ALL ^ E_NOTICE);
177-       }
178+       if ( ! WP_DEBUG )
179+               error_reporting( E_ALL ^ E_NOTICE );
180+
181        // run the tests and print the results
182-       list ($result, $printer) = wptest_run_tests($classes, @$opts['t']);
183-       wptest_print_result($printer,$result);
184+       list( $result, $printer ) = wptest_run_tests( $classes, @$opts['t'] );
185+       wptest_print_result( $printer, $result );
186 }
187-if ( !isset($opts['n']) ) {
188+if ( ! isset($opts['n']) ) {
189        // clean up the database
190        drop_tables();
191 }
192Index: wp-testlib/base.php
193===================================================================
194--- wp-testlib/base.php (revision 320)
195+++ wp-testlib/base.php (working copy)
196@@ -172,10 +172,10 @@
197        function _delete_all_posts() {
198                global $wpdb;
199 
200-               $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}");
201-               if ($all_posts) {
202-                       foreach ($all_posts as $id)
203-                               wp_delete_post($id);
204+               $posts = $wpdb->get_col( "SELECT ID from {$wpdb->posts}" );
205+               if ( $posts ) {
206+                       foreach ( $posts as $id )
207+                               wp_delete_post( $id, true );
208                }
209        }
210 
211@@ -421,19 +421,10 @@
212        }
213 
214        /**
215-        * Skips the current test if there is open WordPress MU ticket with id $ticket_id
216-        */
217-       function knownMUBug($ticket_id) {
218-               if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http://trac.mu.wordpress.org', $ticket_id))) {
219-                       $this->markTestSkipped();
220-               }
221-       }
222-
223-       /**
224         * Skips the current test if there is open plugin ticket with id $ticket_id
225         */
226        function knownPluginBug($ticket_id) {
227-               if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http://dev.wp-plugins.org', $ticket_id))) {
228+               if (!TEST_FORCE_KNOWN_BUGS && (TEST_SKIP_KNOWN_BUGS || !$this->isTracTicketClosed('http://plugins.trac.wordpress.org', $ticket_id))) {
229                        $this->markTestSkipped();
230                }
231        }
232Index: wp-testcase/test_includes_theme.php
233===================================================================
234--- wp-testcase/test_includes_theme.php (revision 320)
235+++ wp-testcase/test_includes_theme.php (working copy)
236@@ -13,14 +13,8 @@
237        function test_get_themes_default() {
238                $themes = get_themes();
239 
240-               // two themes are included by default: Classic and Default
241-               $this->assertTrue(is_array($themes['WordPress Classic']));
242-               if (TEST_MU) {
243-                       $this->assertTrue(is_array($themes['WordPress mu Default']));
244-                       $this->assertTrue(is_array($themes['WordPress mu Default/home']));
245-               }
246-               else
247-                       $this->assertTrue(is_array($themes['WordPress Default']));
248+               // Twenty Ten is the default theme
249+               $this->assertTrue(is_array($themes['Twenty Ten']));
250        }
251 
252        function test_get_themes_contents() {                   
253Index: wp-testcase/test_admin_includes_theme.php
254===================================================================
255--- wp-testcase/test_admin_includes_theme.php   (revision 320)
256+++ wp-testcase/test_admin_includes_theme.php   (working copy)
257@@ -24,7 +24,6 @@
258        }
259       
260        function test_page_templates() {
261-               $this->knownWPBug(10959);
262                $themes = get_themes();
263 
264                $theme = $themes['Page Template Theme'];