<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Tests][875] trunk: Rename the unit tests wp-config.php to wp-tests-config.php.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://unit-tests.trac.wordpress.org/changeset/875">875</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-07-03 17:24:03 +0000 (Tue, 03 Jul 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rename the unit tests wp-config.php to wp-tests-config.php. Also:
 * Rename wp-testdata to data
 * Rename wp-testlib to includes
 * Rename wp-testcase to tests
 * Begin to remove files from the old test suite we no longer need to port code from

fixes <a href="http://unit-tests.trac.wordpress.org/ticket/98">#98</a>. see <a href="http://unit-tests.trac.wordpress.org/ticket/42">#42</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbininstallphp">trunk/bin/install.php</a></li>
<li><a href="#trunkbootstrapphp">trunk/bootstrap.php</a></li>
<li><a href="#trunkphpunitxml">trunk/phpunit.xml</a></li>
<li><a href="#trunkteststest_httpphp">trunk/tests/test_http.php</a></li>
<li><a href="#trunkteststest_import_wpphp">trunk/tests/test_import_wp.php</a></li>
<li><a href="#trunkteststest_includes_functionsphp">trunk/tests/test_includes_functions.php</a></li>
<li><a href="#trunkteststest_post_outputphp">trunk/tests/test_post_output.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/data/</li>
<li>trunk/includes/</li>
<li>trunk/tests/</li>
<li><a href="#trunkwptestsconfigsamplephp">trunk/wp-tests-config-sample.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkdatasample_blogsphp">trunk/data/sample_blogs.php</a></li>
<li><a href="#trunkincludesbasephp">trunk/includes/base.php</a></li>
<li><a href="#trunkincludesgetoptphp">trunk/includes/getopt.php</a></li>
<li><a href="#trunkwpconfigsamplephp">trunk/wp-config-sample.php</a></li>
<li>trunk/wp-testcase/</li>
<li>trunk/wp-testdata/</li>
<li>trunk/wp-testlib/</li>
<li><a href="#trunkwptestsh">trunk/wptest.sh</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/bin/install.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bin/install.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/bin/install.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> 
</span><span class="cx"> define( 'WP_INSTALLING', true );
</span><span class="cx"> require_once $config_file_path;
</span><del>-require_once $config_dir . '/wp-testlib/functions.php';
</del><ins>+require_once $config_dir . '/includes/functions.php';
</ins><span class="cx"> 
</span><span class="cx"> $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
</span><span class="cx"> $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
</span></span></pre></div>
<a id="trunkbootstrapphp"></a>
<div class="modfile"><h4>Modified: trunk/bootstrap.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bootstrap.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/bootstrap.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx"> 
</span><span class="cx"> require_once 'PHPUnit/Autoload.php';
</span><span class="cx"> 
</span><del>-$config_file_path = dirname( __FILE__ ) . '/wp-config.php';
</del><ins>+$config_file_path = dirname( __FILE__ ) . '/wp-tests-config.php';
</ins><span class="cx"> 
</span><span class="cx"> /*
</span><span class="cx">  * Globalize some WordPress variables, because PHPUnit loads this file inside a function
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> 
</span><span class="cx"> require_once $config_file_path;
</span><span class="cx"> 
</span><del>-define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/wp-testdata' );
</del><ins>+define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/data' );
</ins><span class="cx"> 
</span><span class="cx"> if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) )
</span><span class="cx">         define( 'WP_TESTS_FORCE_KNOWN_BUGS', false );
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">         $GLOBALS['base'] = '/';
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-require dirname( __FILE__ ) . '/wp-testlib/functions.php';
</del><ins>+require dirname( __FILE__ ) . '/includes/functions.php';
</ins><span class="cx"> 
</span><span class="cx"> // Preset WordPress options defined in bootstrap file.
</span><span class="cx"> // Used to activate themes, plugins, as well as  other settings.
</span><span class="lines">@@ -67,8 +67,8 @@
</span><span class="cx"> // Delete any default posts &amp; related data
</span><span class="cx"> _delete_all_posts();
</span><span class="cx"> 
</span><del>-require dirname( __FILE__ ) . '/wp-testlib/testcase.php';
-require dirname( __FILE__ ) . '/wp-testlib/testcase-xmlrpc.php';
-require dirname( __FILE__ ) . '/wp-testlib/testcase-ajax.php';
-require dirname( __FILE__ ) . '/wp-testlib/exceptions.php';
-require dirname( __FILE__ ) . '/wp-testlib/utils.php';
</del><ins>+require dirname( __FILE__ ) . '/includes/testcase.php';
+require dirname( __FILE__ ) . '/includes/testcase-xmlrpc.php';
+require dirname( __FILE__ ) . '/includes/testcase-ajax.php';
+require dirname( __FILE__ ) . '/includes/exceptions.php';
+require dirname( __FILE__ ) . '/includes/utils.php';
</ins></span></pre></div>
<a id="trunkdatasample_blogsphp"></a>
<div class="delfile"><h4>Deleted: trunk/data/sample_blogs.php (861 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testdata/sample_blogs.php        2012-07-02 11:00:45 UTC (rev 861)
+++ trunk/data/sample_blogs.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,107 +0,0 @@
</span><del>-&lt;?php
-
-// extend these classes to start with common test cases
-// don't forget to call parent::setUp() and parent::tearDown() if you override them
-
-// an empty blog
-class _WPEmptyBlog extends WPTestCase {
-        var $post_ids = array();
-        var $_setup_check = false;
-
-        function setUp() {
-                parent::setUp();
-
-                $this-&gt;author = get_user_by( 'login', WP_USER_NAME );
-                $this-&gt;_delete_all_posts();
-                update_option('home', 'http://example.com');
-                update_option('siteurl', 'http://example.com');
-                delete_option('permalink_structure');
-                // clear out some caching stuff that's likely to cause unexpected results
-                unset($GLOBALS['cache_lastpostmodified']);
-                $this-&gt;_setup_check = true;
-        }
-
-        function test_setup_check() {
-                // it's easy to forget to call parent::setUp() when extending a base test class
-                // this checks to make sure the base class setUp() was run
-                $this-&gt;assertTrue($this-&gt;_setup_check, get_class($this).' did not call parent::setUp()');
-        }
-}
-
-// a blog with 10 posts
-class _WPSmallBlog extends _WPEmptyBlog {
-        function setUp() {
-                parent::setUp();
-                $this-&gt;_insert_quick_posts(10);
-        }
-}
-
-// a blog with 25 posts and 5 pages
-class _WPMediumBlog extends _WPEmptyBlog {
-        function setUp() {
-                parent::setUp();
-                $this-&gt;_insert_quick_posts(25);
-        }
-}
-
-// a quick way to construct a blog from a WXR export file
-class _WPImportBlog extends _WPEmptyBlog {
-        var $import_filename = NULL;
-
-        function setUp() {
-                parent::setUp();
-
-                if ( ! defined( 'WP_IMPORTING' ) )
-                        define( 'WP_IMPORTING', true );
-                        
-                if ( ! defined( 'WP_LOAD_IMPORTERS' ) )
-                        define( 'WP_LOAD_IMPORTERS', true );
-                        
-                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
-                $this-&gt;_import_wp( DIR_TESTDATA.'/'.$this-&gt;import_filename );
-        }
-}
-
-// a faster way to get the asdftestblog1 dataset than using the importer
-class _WPDataset1 extends _WPEmptyBlog {
-        function setUp() {
-                parent::setUp();
-                $this-&gt;_nuke_main_tables();
-                $this-&gt;_load_sql_dump(DIR_TESTDATA.'/export/asdftestblog1.2007-11-23.sql');
-        }
-        
-        function tearDown() {
-                $this-&gt;_nuke_main_tables();
-                parent::tearDown();
-        }
-        
-        function _nuke_main_tables() {
-                global $wpdb;
-                // crude but effective: make sure there's no residual data in the main tables
-                foreach ( array('posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta') as $table)
-                        $wpdb-&gt;query(&quot;DELETE FROM {$wpdb-&gt;$table}&quot;);
-        }
-}
-
-// a faster way to get the Theme Test Data(test-data.2011-01-17.xml) dataset than using the importer
-class _WPDataset2 extends _WPEmptyBlog {
-        function setUp() {
-                parent::setUp();
-                $this-&gt;_nuke_main_tables();
-                $this-&gt;_load_sql_dump(DIR_TESTDATA . '/export/test-data.2011-01-17.sql');
-        }
-        
-        function tearDown() {
-                $this-&gt;_nuke_main_tables();
-                parent::tearDown();
-        }
-        
-        function _nuke_main_tables() {
-                global $wpdb;
-                // crude but effective: make sure there's no residual data in the main tables
-                foreach ( array('posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta') as $table)
-                        $wpdb-&gt;query(&quot;DELETE FROM {$wpdb-&gt;$table}&quot;);
-        }
-}
-
-?&gt;
</del></span></pre></div>
<a id="trunkincludesbasephp"></a>
<div class="delfile"><h4>Deleted: trunk/includes/base.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testlib/base.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/includes/base.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,674 +0,0 @@
</span><del>-&lt;?php
-
-// abstract most of the unit test framework stuff, so we're not too dependent on one particular test library
-
-#require_once('PHPUnit.php');
-require_once('PHPUnit/Autoload.php');
-require_once('PHPUnit/Util/ErrorHandler.php');
-
-// test cases should extend WPTestCase instead of PHPUnit_TestCase for three reasons:
-
-// 1. it makes it easier to switch to a different unit test framework if necessary
-// 2. you get a bunch of helper methods (see below)
-// 3. The wp-test runner only runs tests that inherit from WPTestCase
-
-class WPTestCase extends PHPUnit_Framework_TestCase {
-
-        protected $backupGlobals = FALSE;
-        var $_time_limit = 120; // max time in seconds for a single test function
-        
-        /**
-         * Whenever a track ticket is checked to see if it's closed or not
-         * the results are stored here
-         * @var array
-         */
-        protected static $trac_ticket_cache = array();
-
-        function setUp() {
-                // error types taken from PHPUnit_Framework_TestResult::run
-                $this-&gt;_phpunit_err_mask = E_USER_ERROR | E_NOTICE | E_STRICT;
-                $this-&gt;_old_handler = set_error_handler(array(&amp;$this, '_error_handler'));
-                if (is_null($this-&gt;_old_handler)) {
-                        restore_error_handler();
-                }
-                _enable_wp_die();
-
-                set_time_limit($this-&gt;_time_limit);
-        }
-
-        function tearDown() {
-                // Multi-level flush, when necessary, if a test did not clean up after themselves.
-                // Avoid flushing the main PHPUnit buffer.
-                $levels = ob_get_level();
-                for ( $i = 1; $i &lt; $levels; $i++ )
-                        ob_end_flush();
-
-                if (!is_null($this-&gt;_old_handler)) {
-                        restore_error_handler();
-                }
-                _enable_wp_die();
-        }
-
-        /**
-         * Treat any error, which wasn't handled by PHPUnit as a failure
-         */
-        function _error_handler($errno, $errstr, $errfile, $errline) {
-                // @ in front of statement
-                if (error_reporting() == 0) {
-                        return;
-                }
-                // notices and strict warnings are passed on to the phpunit error handler but don't trigger an exception
-                if ($errno | $this-&gt;_phpunit_err_mask) {
-                        PHPUnit_Util_ErrorHandler::handleError($errno, $errstr, $errfile, $errline);
-                }
-                // warnings and errors trigger an exception, which is included in the test results
-                else {
-                        error_log(&quot;Testing: $errstr in $errfile on line $errline&quot;);
-                        //TODO: we should raise custom exception here, sth like WP_PHPError
-                        throw new PHPUnit_Framework_Error(
-                                $errstr,
-                                $errno,
-                                $errfile,
-                                $errline,
-                                $trace
-                        );
-                }
-        }
-
-        function _query_filter($q) {
-                $now = microtime(true);
-                $delta = $now - $this-&gt;_q_ts;
-                $this-&gt;_q_ts = $now;
-
-                $bt = debug_backtrace();
-                $caller = '';
-                foreach ($bt as $trace) {
-                        if (strtolower(@$trace['class']) == 'wpdb')
-                                continue;
-                        elseif (strtolower(@$trace['function']) == __FUNCTION__)
-                                continue;
-                        elseif (strtolower(@$trace['function']) == 'call_user_func_array')
-                                continue;
-                        elseif (strtolower(@$trace['function']) == 'apply_filters')
-                                continue;
-
-                        $caller = $trace['function'];
-                        break;
-                }
-
-                #$this-&gt;_queries[] = array($caller, $q);
-                $delta = sprintf('%0.6f', $delta);
-                echo &quot;{$delta} {$caller}: {$q}\n&quot;;
-                @++$this-&gt;_queries[$caller];
-                return $q;
-        }
-
-        // call these to record and display db queries
-        function record_queries() {
-                #$this-&gt;_queries = array();
-                #$this-&gt;_q_ts = microtime(true);
-                #add_filter('query', array(&amp;$this, '_query_filter'));
-                #define('SAVEQUERIES', true);
-                global $wpdb;
-                $wpdb-&gt;queries = array();
-        }
-
-        function dump_queries() {
-                #remove_filter('query', array(&amp;$this, '_query_filter'));
-                #asort($this-&gt;_queries);
-                #dmp($this-&gt;_queries);
-                #$this-&gt;_queries = array();
-                global $wpdb;
-                dmp($wpdb-&gt;queries);
-        }
-
-        function dump_query_summary() {
-                $out = array();
-                global $wpdb;
-                foreach ($wpdb-&gt;queries as $q) {
-                                @$out[$q[2]][0] += 1; // number of queries
-                                @$out[$q[2]][1] += $q[1]; // query time
-                }
-                dmp($out);
-        }
-
-        // pretend that a given URL has been requested
-        function http($url) {
-                // note: the WP and WP_Query classes like to silently fetch parameters
-                // from all over the place (globals, GET, etc), which makes it tricky
-                // to run them more than once without very carefully clearing everything
-                $_GET = $_POST = array();
-                foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v)
-                        unset($GLOBALS[$v]);
-                $parts = parse_url($url);
-                if (isset($parts['scheme'])) {
-                        $req = $parts['path'];
-                        if (isset($parts['query'])) {
-                                $req .= '?' . $parts['query'];
-                                // parse the url query vars into $_GET
-                                parse_str($parts['query'], $_GET);
-                        }
-                }
-                else {
-                        $req = $url;
-                }
-
-                $_SERVER['REQUEST_URI'] = $req;
-                unset($_SERVER['PATH_INFO']);
-
-                wp_cache_flush();
-                unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
-                $GLOBALS['wp_the_query'] =&amp; new WP_Query();
-                $GLOBALS['wp_query'] =&amp; $GLOBALS['wp_the_query'];
-                $GLOBALS['wp'] =&amp; new WP();
-
-                // clean out globals to stop them polluting wp and wp_query
-                foreach ($GLOBALS['wp']-&gt;public_query_vars as $v) {
-                        unset($GLOBALS[$v]);
-                }
-                foreach ($GLOBALS['wp']-&gt;private_query_vars as $v) {
-                        unset($GLOBALS[$v]);
-                }
-
-                $GLOBALS['wp']-&gt;main($parts['query']);
-        }
-
-        // various helper functions for creating and deleting posts, pages etc
-
-        // as it suggests: delete all posts and pages
-        function _delete_all_posts() {
-                global $wpdb;
-
-                $all_posts = $wpdb-&gt;get_col(&quot;SELECT ID from {$wpdb-&gt;posts}&quot;);
-                if ($all_posts) {
-                        foreach ($all_posts as $id)
-                                wp_delete_post( $id, true );
-                }
-        }
-
-        // insert a given number of trivial posts, each with predictable title, content and excerpt
-        function _insert_quick_posts($num, $type='post', $more = array()) {
-                for ($i=0; $i&lt;$num; $i++)
-                        $this-&gt;post_ids[] = wp_insert_post(array_merge(array(
-                                'post_author' =&gt; $this-&gt;author-&gt;ID,
-                                'post_status' =&gt; 'publish',
-                                'post_title' =&gt; &quot;{$type} title {$i}&quot;,
-                                'post_content' =&gt; &quot;{$type} content {$i}&quot;,
-                                'post_excerpt' =&gt; &quot;{$type} excerpt {$i}&quot;,
-                                'post_type' =&gt; $type
-                                ), $more));
-        }
-
-        function _insert_quick_comments($post_id, $num=3) {
-                for ($i=0; $i&lt;$num; $i++) {
-                        wp_insert_comment(array(
-                                'comment_post_ID' =&gt; $post_id,
-                                'comment_author' =&gt; &quot;Commenter $i&quot;,
-                                'comment_author_url' =&gt; &quot;http://example.com/$i/&quot;,
-                                'comment_approved' =&gt; 1,
-                                ));
-                }
-        }
-
-        // insert a given number of trivial pages, each with predictable title, content and excerpt
-        function _insert_quick_pages($num, $more = array()) {
-                $this-&gt;_insert_quick_posts($num, 'page', $more);
-        }
-
-        /**
-         * Import a WXR file.
-         *
-         * The $users parameter provides information on how users specified in the import
-         * file should be imported. Each key is a user login name and indicates if the user
-         * should be mapped to an existing user, created as a new user with a particular login
-         * or imported with the information held in the WXR file. An example of this:
-         *
-         * &lt;code&gt;
-         * $users = array(
-         *   'alice' =&gt; 1, // alice will be mapped to user ID 1
-         *   'bob' =&gt; 'john', // bob will be transformed into john
-         *   'eve' =&gt; false // eve will be imported as is
-         * );&lt;/code&gt;
-         *
-         * @param string $filename Full path of the file to import
-         * @param array $users User import settings
-         * @param bool $fetch_files Whether or not do download remote attachments
-         */
-        function _import_wp( $filename, $users = array(), $fetch_files = true ) {
-                $importer = new WP_Import();
-                $file = realpath( $filename );
-                assert('!empty($file)');
-                assert('is_file($file)');
-
-                $authors = $mapping = array();
-                $i = 0;
-
-                // each user is either mapped to a given ID, mapped to a new user
-                // with given login or imported using details in WXR file
-                foreach ( $users as $user =&gt; $map ) {
-                        $authors[$i] = $user;
-                        if ( is_int( $map ) )
-                                $mapping[$i] = $map;
-                        else if ( is_string( $map ) )
-                                $new[$i] = $map;
-
-                        $i++;
-                }
-
-                $_POST = array( 'imported_authors' =&gt; $authors, 'user_map' =&gt; $mapping, 'user_new' =&gt; $new );
-
-                ob_start();
-                $importer-&gt;fetch_attachments = $fetch_files;
-                $importer-&gt;import( $file );
-                ob_end_clean();
-
-                $_POST = array();
-        }
-
-        // Generate PHP source code containing unit tests for the current blog contents.
-        // When run, the tests will check that the content of the blog exactly matches what it is now,
-        // with a separate test function for each post.
-        function _generate_post_content_test(&amp;$posts, $separate_funcs = true) {
-                global $wpdb;
-
-                $out = '';
-                if (!$separate_funcs)
-                        $out .= &quot;\n\tfunction test_all_posts() {\n&quot;;
-                foreach ($posts as $i=&gt;$post) {
-                        if ($separate_funcs)
-                                $out .= &quot;\n\tfunction test_post_{$i}() {\n&quot;;
-                        $out .= &quot;\t\t\$post = \$this-&gt;posts[{$i}];\n&quot;;
-                        foreach (array_keys(get_object_vars($post)) as $field) {
-                                if ($field == 'guid') {
-                                        if ($post-&gt;post_type == 'attachment')
-                                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(wp_get_attachment_url($post-&gt;ID), $post-&gt;guid);'.&quot;\n&quot;;
-                                        else
-                                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(&quot;'.addcslashes($post-&gt;guid, &quot;\$\n\r\t\&quot;\\&quot;).'&quot;, $post-&gt;guid);'.&quot;\n&quot;;
-                                }
-                                elseif ($field == 'post_parent' and !empty($post-&gt;post_parent)) {
-                                        $parent_index = 0;
-                                        foreach (array_keys($posts) as $index) {
-                                                if ( $posts[$index]-&gt;ID == $post-&gt;post_parent ) {
-                                                        $parent_index = $index;
-                                                        break;
-                                                }
-                                        }
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals($this-&gt;posts['.$parent_index.']-&gt;ID, $post-&gt;post_parent);'.&quot;\n&quot;;
-                                }
-                                elseif ($field == 'post_author')
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(get_profile(\'ID\', \''.($wpdb-&gt;get_var(&quot;SELECT user_login FROM {$wpdb-&gt;users} WHERE ID={$post-&gt;post_author}&quot;)).'\'), $post-&gt;post_author);'.&quot;\n&quot;;
-                                elseif ($field != 'ID')
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(&quot;'.addcslashes($post-&gt;$field, &quot;\$\n\r\t\&quot;\\&quot;).'&quot;, $post-&gt;'.$field.');'.&quot;\n&quot;;
-                        }
-                        $cats = wp_get_post_categories($post-&gt;ID, array('fields'=&gt;'all'));
-                        $out .= &quot;\t\t&quot;.'$cats = wp_get_post_categories($post-&gt;ID, array(&quot;fields&quot;=&gt;&quot;all&quot;));'.&quot;\n&quot;;
-                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals('.count($cats).', count($cats));'.&quot;\n&quot;;
-                        if ($cats) {
-                                foreach ($cats as $j=&gt;$cat) {
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($cat-&gt;name).'\', $cats['.$j.']-&gt;name);'.&quot;\n&quot;;
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($cat-&gt;slug).'\', $cats['.$j.']-&gt;slug);'.&quot;\n&quot;;
-                                }
-                        }
-
-                        $tags = wp_get_post_tags($post-&gt;ID);
-                        $out .= &quot;\t\t&quot;.'$tags = wp_get_post_tags($post-&gt;ID);'.&quot;\n&quot;;
-                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals('.count($tags).', count($tags));'.&quot;\n&quot;;
-                        if ($tags) {
-                                foreach ($tags as $j=&gt;$tag) {
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($tag-&gt;name).'\', $tags['.$j.']-&gt;name);'.&quot;\n&quot;;
-                                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($tag-&gt;slug).'\', $tags['.$j.']-&gt;slug);'.&quot;\n&quot;;
-                                }
-                        }
-
-                        $meta = $wpdb-&gt;get_results(&quot;SELECT DISTINCT meta_key FROM {$wpdb-&gt;postmeta} WHERE post_id = $post-&gt;ID&quot;);
-                        #$out .= &quot;\t\t&quot;.'$this-&gt;assertEquals('.count($postmeta).', count($meta));'.&quot;\n&quot;;
-                        foreach ($meta as $m) {
-                                #$out .= &quot;\t\t&quot;.'$meta = get_post_meta($post-&gt;ID, \''.addslashes($m-&gt;meta_key).'\', true);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals('.var_export(get_post_meta($post-&gt;ID, $m-&gt;meta_key, false), true).', get_post_meta($post-&gt;ID, \''.addslashes($m-&gt;meta_key).'\', false));'.&quot;\n&quot;;
-                        }
-
-
-                        $comments = $wpdb-&gt;get_results($wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;comments WHERE comment_post_ID = %d ORDER BY comment_date DESC&quot;, $post-&gt;ID));
-
-                        $out .= &quot;\t\t&quot;.'$comments = $wpdb-&gt;get_results($wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;comments WHERE comment_post_ID = %d ORDER BY comment_date DESC&quot;, $post-&gt;ID));'.&quot;\n&quot;;
-                        $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals('.count($comments).', count($comments));'.&quot;\n&quot;;
-                        foreach ($comments as $k=&gt;$comment) {
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_author).'\', $comments['.$k.']-&gt;comment_author);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_author_email).'\', $comments['.$k.']-&gt;comment_author_email);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_author_url).'\', $comments['.$k.']-&gt;comment_author_url);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_author_IP).'\', $comments['.$k.']-&gt;comment_author_IP);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_date).'\', $comments['.$k.']-&gt;comment_date);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_date_gmt).'\', $comments['.$k.']-&gt;comment_date_gmt);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_karma).'\', $comments['.$k.']-&gt;comment_karma);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_approved).'\', $comments['.$k.']-&gt;comment_approved);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_agent).'\', $comments['.$k.']-&gt;comment_agent);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_type).'\', $comments['.$k.']-&gt;comment_type);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_parent).'\', $comments['.$k.']-&gt;comment_parent);'.&quot;\n&quot;;
-                                $out .= &quot;\t\t&quot;.'$this-&gt;assertEquals(\''.addslashes($comment-&gt;comment_user_id).'\', $comments['.$k.']-&gt;comment_user_id);'.&quot;\n&quot;;
-                        }
-
-
-                        if ($separate_funcs)
-                                $out .= &quot;\t}\n\n&quot;;
-                        else
-                                $out .= &quot;\n\n&quot;;
-                }
-                if (!$separate_funcs)
-                        $out .= &quot;\t}\n\n&quot;;
-                return $out;
-        }
-
-        function _dump_tables($table /*, table2, .. */) {
-                $args = func_get_args();
-                $table_list = join(' ', $args);
-                system('mysqldump -u '.DB_USER.' --password='.DB_PASSWORD.' -cqnt '.DB_NAME.' '.$table_list);
-        }
-
-        function _load_sql_dump($file) {
-                $lines = file($file);
-
-                global $wpdb;
-                foreach ($lines as $line) {
-                        $line = trim( $line );
-                        if ( empty( $line ) || 0 === strpos( $line, '--' ) || 0 === strpos( $line, '/*' ) )
-                                continue;
-                        $wpdb-&gt;query($line);
-                }
-        }
-
-        // add a user of the specified type
-        function _make_user($role = 'administrator', $user_login = '', $pass='', $email='') {
-                if (!$user_login)
-                        $user_login = rand_str();
-                if (!$pass)
-                        $pass = rand_str();
-                if (!$email)
-                        $email = rand_str().'@example.com';
-
-                // we're testing via the add_user()/edit_user() functions, which expect POST data
-                $_POST = array(
-                        // 'role' =&gt; $role, Set this later
-                        'user_login' =&gt; $user_login,
-                        'pass1' =&gt; $pass,
-                        'pass2' =&gt; $pass,
-                        'email' =&gt; $email,
-                        'description' =&gt; $user_login,
-                );
-
-                $this-&gt;user_ids[] = $id = add_user();
-
-                $user = new WP_User( $id );
-                $user-&gt;set_role( $role );
-
-                $_POST = array();
-                return $id;
-        }
-
-        function _destroy_user( $user_id ) {
-                if ( is_multisite() )
-                        wpmu_delete_user( $user_id );
-                else
-                        wp_delete_user( $user_id );
-        }
-
-        function _destroy_users() {
-                array_map( array( $this, '_destroy_user' ), $this-&gt;user_ids );
-        }
-
-        function _destroy_uploads() {
-                $uploads = wp_upload_dir(); 
-                foreach ( scandir( $uploads['basedir'] ) as $file )
-                        _rmdir( $uploads['basedir'] . '/' . $file ); 
-        }
-
-        /**
-         * Checks if track ticket #$ticket_id is resolved
-         *
-         * @return bool|null true if the ticket is resolved, false if not resolved, null on error
-         */
-        function isTracTicketClosed($trac_url, $ticket_id) {
-                $trac_url = rtrim($trac_url, '/');
-                $url = &quot;$trac_url/ticket/$ticket_id?format=tab&quot;;                
-                if ( array_key_exists( $url, self::$trac_ticket_cache ) ) {
-                        return self::$trac_ticket_cache[$url];
-                }
-                $ticket_tsv = file_get_contents($url);                
-                if (false === $ticket_tsv) {
-                        self::$trac_ticket_cache[$url] = null;
-                        return self::$trac_ticket_cache[$url];
-                }
-                $lines = explode(&quot;\n&quot;, $ticket_tsv, 2);
-                if (!is_array($lines) || count($lines) &lt; 2) {
-                        self::$trac_ticket_cache[$url] = null;
-                        return self::$trac_ticket_cache[$url];
-                }
-                $titles = str_getcsv( $lines[0], &quot;\t&quot; );
-                $status_idx = array_search('status', $titles);
-                if (false === $status_idx) {
-                        self::$trac_ticket_cache[$url] = null;
-                        return self::$trac_ticket_cache[$url];
-                }
-                $tabs = str_getcsv( $lines[1], &quot;\t&quot; );
-                self::$trac_ticket_cache[$url] = ( 'closed' === $tabs[$status_idx] );
-                return self::$trac_ticket_cache[$url];
-        }
-
-        /**
-         * Skips the current test if there is open WordPress ticket with id $ticket_id
-         */
-        function knownWPBug($ticket_id) {
-                if (!TEST_FORCE_KNOWN_BUGS &amp;&amp; (TEST_SKIP_KNOWN_BUGS || !$this-&gt;isTracTicketClosed('http://core.trac.wordpress.org', $ticket_id))) {
-                        $this-&gt;markTestSkipped( sprintf('WordPress Ticket #%d is not fixed', $ticket_id) );
-                }
-        }
-
-        /**
-         * Skips the current test if there is open unit tests ticket with id $ticket_id
-         */
-        function knownUTBug($ticket_id) {
-                if (!TEST_FORCE_KNOWN_BUGS &amp;&amp; (TEST_SKIP_KNOWN_BUGS || !$this-&gt;isTracTicketClosed('http://unit-tests.trac.wordpress.org', $ticket_id))) {
-                        $this-&gt;markTestSkipped( sprintf('Unit Tests Ticket #%d is not fixed', $ticket_id) );
-                }
-        }
-
-        /**
-         * Skips the current test if there is open WordPress MU ticket with id $ticket_id
-         */
-        function knownMUBug($ticket_id) {
-                if (!TEST_FORCE_KNOWN_BUGS &amp;&amp; (TEST_SKIP_KNOWN_BUGS || !$this-&gt;isTracTicketClosed('http://trac.mu.wordpress.org', $ticket_id))) {
-                        $this-&gt;markTestSkipped( sprintf('WordPress MU Ticket #%d is not fixed', $ticket_id) );
-                }
-        }
-
-        /**
-         * Skips the current test if there is open plugin ticket with id $ticket_id
-         */
-        function knownPluginBug($ticket_id) {
-                if (!TEST_FORCE_KNOWN_BUGS &amp;&amp; (TEST_SKIP_KNOWN_BUGS || !$this-&gt;isTracTicketClosed('http://dev.wp-plugins.org', $ticket_id))) {
-                        $this-&gt;markTestSkipped( sprintf('WordPress Plugin Ticket #%d is not fixed', $ticket_id) );
-                }
-        }
-        /**
-         * Skips the current test if the PHP version is not high enough
-         */
-        function checkAtLeastPHPVersion($ver) {
-                if ( version_compare(PHP_VERSION, $ver, '&lt;') ) {
-                        $this-&gt;markTestSkipped();
-                }
-        }
-
-        /**
-         * Skips the current test the given PHP extension is not loaded
-         * @param string $ext  the PHP extension name to check
-         * @return void
-         */
-        function checkPHPExtension($ext) {
-                if ( !extension_loaded($ext) ) {
-                        $this-&gt;markTestSkipped(&quot;The $ext PHP extension is not loaded.&quot;);
-                }
-        }
-
-        // convenience function: return the # of posts associated with a tag
-        function _tag_count($name) {
-                $t = get_term_by('name', $name, 'post_tag');
-                if ($t)
-                        return $t-&gt;count;
-        }
-
-        // convenience function: return the # of posts associated with a category
-        function _category_count($name) {
-                $t = get_term_by('name', $name, 'category');
-                if ($t)
-                        return $t-&gt;count;
-        }
-
-}
-
-// simple functions for loading and running tests
-function wptest_get_all_test_files($dir) {
-        $tests = array();
-        $files = scandir($dir);
-        foreach ( $files as $file ) {
-                if ($file[0] == '.')
-                                continue;
-                // skip test loaders from jacob's tests
-                if (strtolower($file) == 'alltests.php')
-                        continue;
-                // these tests clash with other things
-                if (in_array(strtolower($file), array('testplugin.php', 'testlocale.php')))
-                        continue;
-                $path = realpath($dir . DIRECTORY_SEPARATOR . $file);
-                $fileparts = pathinfo($file);
-                if (is_file($path) and $fileparts['extension'] == 'php')
-                        $tests[] = $path;
-                elseif (is_dir($path))
-                        $tests = array_merge($tests, wptest_get_all_test_files($path));
-        }
-        return $tests;
-}
-
-function wptest_is_descendent($parent, $class) {
-
-        $ancestor = strtolower(get_parent_class($class));
-
-        while ($ancestor) {
-                if ($ancestor == strtolower($parent)) return true;
-                $ancestor = strtolower(get_parent_class($ancestor));
-        }
-
-        return false;
-}
-
-function wptest_get_all_test_cases() {
-        $test_classes = array();
-        $all_classes = get_declared_classes();
-        // only classes that extend WPTestCase and have names that don't start with _ are included
-        foreach ($all_classes as $class)
-                if ($class{0} != '_' and wptest_is_descendent('WPTestCase', $class))
-                        $test_classes[] = $class;
-        return $test_classes;
-}
-
-/**
- * Simple function to list out all the test cases for command line interfaces
- *
- * @param $test_classes The test casses array as returned by wptest_get_all_test_cases()
- * @return none
- */
-function wptest_listall_testcases($test_classes) {
-        echo &quot;\nWordPress Tests available TestCases:\n\n&quot;;
-        natcasesort( $test_classes );
-        echo array_reduce($test_classes, '_wptest_listall_testcases_helper');
-        echo &quot;\nUse -t TestCaseName to run individual test cases\n&quot;;
-}
-
-function _wptest_listall_testcases_helper( $current, $item ) {
-        return $current . &quot;\t{$item}\n&quot;;
-}
-
-function wptest_run_tests($classes, $classnames = array(), $filter = null ) {
-        $suite = new PHPUnit_Framework_TestSuite();
-
-        if ( ! is_array($classnames) ) // For strings, Accept a comma separated list, or a space separated list.
-                $classnames = preg_split('![,\s]+!', $classnames);
-
-        $classnames = array_map('strtolower', $classnames);
-        $classnames = array_filter($classnames); //strip out any empty items
-
-        foreach ( $classes as $testcase ) {
-                if ( ( empty($classnames) || in_array( strtolower( $testcase ), $classnames ) ) &amp;&amp;
-                         ( is_null( $filter ) || strstr( $testcase, $filter ) )
-                        ) {
-                        $suite-&gt;addTestSuite($testcase);
-                }
-        }
-
-        #return PHPUnit::run($suite);
-        $result = new PHPUnit_Framework_TestResult;
-        require_once('PHPUnit/TextUI/ResultPrinter.php');
-        $printer = new PHPUnit_TextUI_ResultPrinter(NULL, WP_PHPUNIT_VERBOSE, !stristr(PHP_OS, 'WIN') );
-        $result-&gt;addListener($printer);
-        return array($suite-&gt;run($result, FALSE ), $printer);
-}
-
-function wptest_print_result($printer, $result) {
-        $printer-&gt;printResult($result, timer_stop());
-        /*
-        echo $result-&gt;toString();
-        echo &quot;\n&quot;, str_repeat('-', 40), &quot;\n&quot;;
-        if ($f = intval($result-&gt;failureCount()))
-                echo &quot;$f failures\n&quot;;
-        if ($e = intval($result-&gt;errorCount()))
-                echo &quot;$e errors\n&quot;;
-
-        if (!$f and !$e)
-                echo &quot;PASS (&quot;.$result-&gt;runCount().&quot; tests)\n&quot;;
-        else
-                echo &quot;FAIL (&quot;.$result-&gt;runCount().&quot; tests)\n&quot;;
-        */
-}
-
-/**
- * Base class for XML-RPC tests.
- *
- * Initializes XML-RPC server instance and creates set of users.
- */
-abstract class WPXMLRPCServerTestCase extends WPTestCase {
-        var $myxmlrpcserver;
-        var $user_ids = array();
-
-        function setUp() {
-
-                parent::setUp();
-                // keep track of users we create
-                $this-&gt;user_ids = array();
-                $this-&gt;_flush_roles();
-
-                add_filter( 'pre_option_enable_xmlrpc', '__return_true' );
-
-                $this-&gt;_make_user( 'subscriber', 'subscriber', 'subscriber' );
-                $this-&gt;_make_user( 'contributor', 'contributor', 'contributor' );
-                $this-&gt;_make_user( 'author', 'author', 'author' );
-                $this-&gt;_make_user( 'editor', 'editor', 'editor' );
-                $this-&gt;_make_user( 'administrator', 'administrator', 'administrator' );
-
-                $this-&gt;myxmlrpcserver = new wp_xmlrpc_server();
-        }
-
-        function tearDown() {
-                parent::tearDown();
-                // delete any users and uploads that were created during tests
-                $this-&gt;_destroy_users();
-                $this-&gt;_destroy_uploads();
-
-                remove_filter( 'pre_option_enable_xmlrpc', '__return_true' );
-        }
-
-        function _flush_roles() {
-                // we want to make sure we're testing against the db, not just in-memory data
-                // this will flush everything and reload it from the db
-                unset( $GLOBALS['wp_user_roles'] );
-        }
-}
-
-?&gt;
</del></span></pre></div>
<a id="trunkincludesgetoptphp"></a>
<div class="delfile"><h4>Deleted: trunk/includes/getopt.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testlib/getopt.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/includes/getopt.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,374 +0,0 @@
</span><del>-&lt;?php
-/**
- * getopt relacement / extenstion
- *
- *  prior to PHP 5.3 getopt is not supported on the windows plattform
- *  and it does not support long options on other plattforms as well.
- *
- *  this file offers a _getopt() function as a replacement. via the
- *  php.net manual page for getop().
- *
- *  original author is 可愛柚爸 / uberlinuxguy at tulg dot org
- *
- *  the function has been taken from that website, and refactored
- *  into a helper class to increase the protability
- *
- * @version 1.0 hakre-1
- *
- *  CHANGELOG:
- *
- *   - refactored the functions into a class (better portability)
- *   - reformatted the code (copy &amp; paste issues)
- *   - removed eval calls (commented)
- *   - smarter quoting
- *   - indentation on tab and cleanup of whitespaces
- *   - deprecated string access ({}) fixed with [].
- *
- *  TODO:
- *   (empty)
- *
- *
- *  @link http://www.ntu.beautifulworldco.com/weblog/?p=526
- *  @link http://www.php.net/getopt
- */
-
-/**
- * getoptParser
- *
- * getopt() compatible argv parsing.
- *
- * @see getoptParser::getopt()
- * @see getoptParser::split_para()
- */
-class getoptParser {
-        /**
-         * getopt()
-         *
-         * Usage: _getopt ( [$flag,] $short_option [, $long_option] );
-         *
-         * Note that another function split_para() is required, which can be
-         * found in the same page.
-         *
-         * _getopt() fully simulates getopt() which is described at
-         * (@see http://us.php.net/manual/en/function.getopt.php} , including long
-         * options for PHP version under 5.3.0. (Prior to 5.3.0, long options was
-         * only available on few systems)
-         *
-         * Besides legacy usage of getopt(), I also added a new option to manipulate
-         * your own argument lists instead of those from command lines. This new
-         * option can be a string or an array such as
-         *
-         *  $flag = &quot;-f value_f -ab --required 9 --optional=PK --option -v test -k&quot;;
-         *
-         *  or
-         *
-         *  $flag = array ( &quot;-f&quot;, &quot;value_f&quot;, &quot;-ab&quot;, &quot;--required&quot;, &quot;9&quot;, &quot;--optional=PK&quot;, &quot;--option&quot; );
-         *
-         *  So there are four ways to work with _getopt(),
-         *
-         *  1. _getopt ( $short_option );
-         *        it's a legacy usage, same as getopt ( $short_option ).
-         *
-         *  2. _getopt ( $short_option, $long_option );
-         *        it's a legacy usage, same as getopt ( $short_option, $long_option ).
-         *
-         *  3. _getopt ( $flag, $short_option );
-         *        use your own argument lists instead of command line arguments.
-         *
-         *  4. _getopt ( $flag, $short_option, $long_option );
-         *        use your own argument lists instead of command line arguments.
-         *
-         * @version 1.3
-         * @date 2009/05/30 (taken from the website 2010-01-11)
-         * @author 可愛柚爸 / uberlinuxguy at tulg dot org
-         * @see http://www.ntu.beautifulworldco.com/weblog/?p=526
-         *
-         * @params mixed
-         * @return array
-         */
-        static function getopt() {
-
-                if ( func_num_args() == 1 ) {
-                        $flag =  $flag_array = $GLOBALS['argv'];
-                        $short_option = func_get_arg ( 0 );
-                        $long_option = array ();
-                } elseif ( func_num_args() == 2 ) {
-                        if ( is_array ( func_get_arg ( 1 ) ) ) {
-                        $flag = $GLOBALS['argv'];
-                        $short_option = func_get_arg ( 0 );
-                        $long_option = func_get_arg ( 1 );
-                        } else {
-                        $flag = func_get_arg ( 0 );
-                        $short_option = func_get_arg ( 1 );
-                        $long_option = array ();
-                        }
-                } elseif ( func_num_args() == 3 ) {
-                        $flag = func_get_arg ( 0 );
-                        $short_option = func_get_arg ( 1 );
-                        $long_option = func_get_arg ( 2 );
-                } else {
-                        exit ( &quot;wrong options\n&quot; );
-                }
-
-                $short_option         = trim($short_option);
-                $short_no_value       = array();
-                $short_required_value = array();
-                $short_optional_value = array();
-                $long_no_value        = array();
-                $long_required_value  = array();
-                $long_optional_value  = array();
-                $options              = array();
-
-                for ( $i = 0; $i &lt; strlen ( $short_option ); ) {
-                        if ( $short_option[$i] != ':' ) {
-                                if ( $i == strlen ( $short_option ) - 1 ) {
-                                        $short_no_value[] = $short_option[$i];
-                                        break;
-                                } elseif ( $short_option[$i+1] != ':' ) {
-                                        $short_no_value[] = $short_option[$i];
-                                        $i++;
-                                        continue;
-                                } elseif ( $short_option[$i+1] == ':' &amp;&amp; $short_option[$i+2] != ':' ) {
-                                        $short_required_value[] = $short_option[$i];
-                                        $i += 2;
-                                        continue;
-                                } elseif ( $short_option[$i+1] == ':' &amp;&amp; $short_option[$i+2] == ':' ) {
-                                        $short_optional_value[] = $short_option[$i];
-                                        $i += 3;
-                                        continue;
-                                }
-                        } else {
-                                continue;
-                        }
-                }
-
-                foreach ( $long_option as $a ) {
-                        if ( substr( $a, -2 ) == '::' ) {
-                                $long_optional_value[] = substr($a, 0, -2);
-                        } elseif ( substr($a, -1) == ':' ) {
-                                $long_required_value[] = substr($a, 0, -1);
-                        } else {
-                                $long_no_value[] = $a;
-                        }
-                }
-
-                if ( is_array ( $flag ) ) {
-                        $flag_array = $flag;
-                } else {
-                        $flag = &quot;- $flag&quot;;
-                        $flag_array = self::_split_para($flag);
-                }
-
-                for ( $i = 0; $i &lt; count($flag_array); ) {
-
-                        if ( !$flag_array[$i] || ( '-' == $flag_array[$i] ) ) {
-                                $i++;
-                                continue;
-                        } elseif ( '-' != $flag_array[$i][0] ) {
-                                $i++;
-                                continue;
-                        }
-
-                        if ( substr($flag_array[$i], 0, 2) == '--' ) {
-                                if (strpos($flag_array[$i], '=') != false) {
-                                        list($key, $value) = explode('=', substr($flag_array[$i], 2), 2);
-                                        if ( in_array($key, $long_required_value ) || in_array($key, $long_optional_value ) )
-                                                $options[$key][] = $value;
-                                        $i++;
-                                        continue;
-                                } elseif (strpos($flag_array[$i], '=') == false) {
-                                        $key = substr($flag_array[$i], 2);
-                                        if ( in_array(substr( $flag_array[$i], 2 ), $long_required_value ) ) {
-                                                $options[$key][] = $flag_array[$i+1];
-                                                $i++;
-                                        } elseif ( in_array(substr( $flag_array[$i], 2 ), $long_optional_value ) ) {
-                                                if ( $flag_array[$i+1] != '' &amp;&amp; $flag_array[$i+1][0] != '-' ) {
-                                                        $options[$key][] = $flag_array[$i+1];
-                                                        $i++;
-                                                } else {
-                                                        $options[$key][] = FALSE;
-                                                }
-                                        } elseif ( in_array(substr( $flag_array[$i], 2 ), $long_no_value ) ) {
-                                                $options[$key][] = FALSE;
-                                        }
-                                        $i++;
-                                        continue;
-                                }
-                        } elseif ( $flag_array[$i][0] == '-' &amp;&amp; $flag_array[$i][1] != '-' ) {
-                                for ( $j=1; $j &lt; strlen($flag_array[$i]); $j++ ) {
-                                        if ( in_array($flag_array[$i][$j], $short_required_value ) || in_array($flag_array[$i][$j], $short_optional_value )) {
-                                                if ( $j == strlen($flag_array[$i]) - 1  ) {
-                                                        if ( in_array($flag_array[$i][$j], $short_required_value ) ) {
-                                                                if (isset($flag_array[$i+1]))
-                                                                        $options[$flag_array[$i][$j]][] = $flag_array[$i+1];
-                                                                $i++;
-                                                        } elseif ( in_array($flag_array[$i][$j], $short_optional_value ) &amp;&amp; $flag_array[$i+1] != '' &amp;&amp; $flag_array[$i+1][0] != '-' ) {
-                                                                $options[$flag_array[$i][$j]][] = $flag_array[$i+1];
-                                                                $i++;
-                                                        } else {
-                                                                $options[$flag_array[$i][$j]][] = FALSE;
-                                                        }
-                                                } else {
-                                                        $options[$flag_array[$i][$j]][] = substr ( $flag_array[$i], $j + 1 );
-                                                }
-                                                $plus_i = 0;
-                                                $i++;
-                                                break;
-                                        } elseif ( in_array($flag_array[$i][$j], $short_no_value ) ) {
-                                                $options[$flag_array[$i][$j]][] = FALSE;
-                                                $plus_i = 1;
-                                                continue;
-                                        } else {
-                                                $plus_i = 1;
-                                                break;
-                                        }
-                                }
-                                $i += $plus_i;
-                                continue;
-                        } // if
-                        $i++;
-                } // for
-
-                // reduce options array depth if possible
-                foreach ( $options as $key =&gt; $value ) {
-                        if ( count($value) == 1 )
-                                $options[$key] = $value[0];
-                }
-
-                return $options;
-
-        }
-
-        /**
-         * split parameters
-         *
-         * static helper function
-         *
-         * @version 1.0
-         * @date    2008/08/19
-         * @see     http://www.ntu.beautifulworldco.com/weblog/?p=526
-         *
-         * This function is to parse parameters and split them into smaller pieces.
-         * preg_split() does similar thing but in our function, besides &quot;space&quot;, we
-         * also take the three symbols &quot; (double quote), '(single quote),
-         * and \ (backslash) into consideration because things in a pair of &quot; or '
-         * should be grouped together.
-         *
-         * As an example, this parameter list
-         *
-         * -f &quot;test 2&quot; -ab --required &quot;t\&quot;est 1&quot; --optional=&quot;te'st 3&quot; --option -v 'test 4'
-         *
-         * will be splited into
-         *
-         * -f; test 2; -ab; --required; t&quot;est 1; --optional=te'st 3; --option; -v; test 4
-         *
-         * see the code below:
-         *
-         * &lt;code&gt;
-         *        $pattern = &quot;-f \&quot;test 2\&quot; -ab --required \&quot;t\\\&quot;est 1\&quot; --optional=\&quot;te'st 3\&quot; --option -v 'test 4'&quot;;
-         *        $result = getoptParser::split_para($pattern);
-         *        echo &quot;ORIGINAL PATTERN: $pattern\n\n&quot;;
-         *        var_dump($result);
-         * &lt;/code&gt;
-         *
-         * @param string $pattern
-         * @return array
-         */
-        public static function split_para($pattern) {
-                $begin      = 0;
-                $backslash  = 0;
-                $quote      = '';
-                $quote_mark = array();
-                $result     = array();
-                $pattern        = trim($pattern);
-                $cand1      = '';
-
-                for ( $end = 0; $end &lt; strlen($pattern); ) {
-                        if ( !in_array($pattern[$end], array(' ', '&quot;', &quot;'&quot;, &quot;\\&quot;)) ) {
-                                $backslash = 0;
-                                $end++;
-                                continue;
-                        }
-                        if ( $pattern[$end] == &quot;\\&quot; ) {
-                                $backslash++;
-                                $end++;
-                                continue;
-                        } elseif ( $pattern[$end] == '&quot;' ) {
-                                if ( $backslash % 2 == 1 || $quote == &quot;'&quot; ) {
-                                        $backslash = 0;
-                                        $end++;
-                                        continue;
-                                }
-                                if ( $quote == '' ) {
-                                        $quote_mark[] = $end - $begin;
-                                        $quote = '&quot;';
-                                } elseif ( $quote == '&quot;' ) {
-                                        $quote_mark[] = $end - $begin;
-                                        $quote = '';
-                                }
-
-                                $backslash = 0;
-                                $end++;
-                                continue;
-                        } elseif ( $pattern[$end] == &quot;'&quot; ) {
-                                if ( $backslash % 2 == 1 || $quote == '&quot;' ) {
-                                        $backslash = 0;
-                                        $end++;
-                                        continue;
-                                }
-                                if ( $quote == '' ) {
-                                        $quote_mark[] = $end - $begin;
-                                        $quote = &quot;'&quot;;
-                                } elseif ( $quote == &quot;'&quot; ) {
-                                        $quote_mark[] = $end - $begin;
-                                        $quote = '';
-                                }
-
-                                $backslash = 0;
-                                $end++;
-                                continue;
-                        } elseif ( $pattern[$end] == ' ' ) {
-                                if ( $quote != '' ) {
-                                        $backslash = 0;
-                                        $end++;
-                                        continue;
-                                } else {
-                                        $backslash = 0;
-                                        $cand = substr($pattern, $begin, $end-$begin);
-                                        for ( $j = 0; $j &lt; strlen($cand); $j++ ) {
-                                                if ( in_array($j, $quote_mark) )
-                                                        continue;
-
-                                        $cand1 .= $cand[$j];
-                                }
-                                if ( $cand1 ) {
-                                        // commented and replaced:
-                                        // eval( &quot;\$cand1 = \&quot;$cand1\&quot;;&quot; );
-                                        $result[] = (string) $cand1;
-                                }
-                                $quote_mark = array();
-                                $cand1 = '';
-                                $begin =++$end;
-                                continue;
-                                }
-                        }
-                }
-
-                $cand = substr($pattern, $begin, $end-$begin);
-                for ( $j = 0; $j &lt; strlen($cand); $j++ ) {
-                        if ( in_array($j, $quote_mark ) )
-                                continue;
-                        $cand1 .= $cand[$j];
-                }
-
-                // commented and replaced:
-                // eval( &quot;\$cand1 = \&quot;$cand1\&quot;;&quot; );
-                $cand1 = (string) $cand1;
-
-                if ( $cand1 )
-                        $result[] = $cand1;
-
-                return $result;
-        }
-}
-?&gt;
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkphpunitxml"></a>
<div class="modfile"><h4>Modified: trunk/phpunit.xml (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/phpunit.xml        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/phpunit.xml        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -6,9 +6,9 @@
</span><span class="cx">     &lt;testsuites&gt;
</span><span class="cx">         &lt;!-- Default test suite to run all tests --&gt;
</span><span class="cx">         &lt;testsuite&gt;
</span><del>-            &lt;directory suffix=&quot;.php&quot;&gt;wp-testcase&lt;/directory&gt;
-            &lt;file phpVersion=&quot;5.3.0&quot; phpVersionOperator=&quot;&gt;=&quot;&gt;wp-testcase/test_actions_closures.php&lt;/file&gt;
-            &lt;exclude&gt;wp-testcase/test_query_results.php&lt;/exclude&gt;
</del><ins>+            &lt;directory suffix=&quot;.php&quot;&gt;tests&lt;/directory&gt;
+            &lt;file phpVersion=&quot;5.3.0&quot;&gt;tests/test_actions_closures.php&lt;/file&gt;
+            &lt;exclude&gt;tests/test_query_results.php&lt;/exclude&gt;
</ins><span class="cx">         &lt;/testsuite&gt;
</span><span class="cx">     &lt;/testsuites&gt;
</span><span class="cx"> &lt;/phpunit&gt;
</span></span></pre></div>
<a id="trunkteststest_httpphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/test_http.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testcase/test_http.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/tests/test_http.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx">  * @group http
</span><span class="cx">  */
</span><span class="cx"> abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
</span><del>-        // You can use your own version of wp-testdata/WPHTTP-testcase-redirection-script.php here.
</del><ins>+        // You can use your own version of data/WPHTTP-testcase-redirection-script.php here.
</ins><span class="cx">         var $redirection_script = 'http://api.wordpress.org/core/tests/1.0/redirection.php';
</span><span class="cx"> 
</span><span class="cx">         function setUp() {
</span><span class="lines">@@ -156,7 +156,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_file_stream() {
</span><del>-                $url = 'http://unit-tests.svn.wordpress.org/trunk/wp-testdata/images/2004-07-22-DSC_0007.jpg'; // we'll test against a file in the unit test data
</del><ins>+                $url = 'http://unit-tests.svn.wordpress.org/trunk/data/images/2004-07-22-DSC_0007.jpg'; // we'll test against a file in the unit test data
</ins><span class="cx">                 $size = 87348;
</span><span class="cx">                 $res = wp_remote_request( $url, array( 'stream' =&gt; true, 'timeout' =&gt; 30 ) ); //Auto generate the filename.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkteststest_import_wpphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/test_import_wp.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testcase/test_import_wp.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/tests/test_import_wp.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,9 +1,5 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-#include_once(DIR_TESTROOT.'/wp-testlib/wp-profiler.php');
-
-// need to include the importer as an external, so path may need to change...
-
</del><span class="cx"> abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
</span><span class="cx">         /**
</span><span class="cx">          * Import a WXR file.
</span></span></pre></div>
<a id="trunkteststest_includes_functionsphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/test_includes_functions.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testcase/test_includes_functions.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/tests/test_includes_functions.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> 
</span><span class="cx">         function test_wp_unique_filename() {
</span><span class="cx">                 /* this test requires:
</span><del>-                   - that you have dir + file 'wp-testdata/images/test-image.png',
</del><ins>+                   - that you have dir + file 'data/images/test-image.png',
</ins><span class="cx">                    - and that this dir is writeable
</span><span class="cx">                    - there is an image 'test-image.png' that will be used to test unique filenames
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkteststest_post_outputphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/test_post_output.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testcase/test_post_output.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/tests/test_post_output.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">         function test_the_content() {
</span><span class="cx">                 // permalink page
</span><span class="cx">                 $link = '/2008/04/01/simple-gallery-test/';
</span><del>-                $this-&gt;http('/2008/04/01/simple-gallery-test/');
</del><ins>+                $this-&gt;go_to('/2008/04/01/simple-gallery-test/');
</ins><span class="cx">                 the_post();
</span><span class="cx">                 // filtered output
</span><span class="cx">                 $out = get_echo('the_content');
</span><span class="lines">@@ -216,7 +216,7 @@
</span><span class="cx">                 wp_update_post($post);
</span><span class="cx"> 
</span><span class="cx">                 // permalink page
</span><del>-                $this-&gt;http('/2008/04/01/simple-gallery-test/');
</del><ins>+                $this-&gt;go_to('/2008/04/01/simple-gallery-test/');
</ins><span class="cx">                 the_post();
</span><span class="cx">                 // filtered output
</span><span class="cx">                 $out = get_echo('the_content');
</span></span></pre></div>
<a id="trunkwpconfigsamplephp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-config-sample.php (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-config-sample.php        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/wp-config-sample.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,46 +0,0 @@
</span><del>-&lt;?php
-
-/* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */
-define( 'ABSPATH', dirname( __FILE__ ) . '/wordpress/' );
-
-// Test with multisite enabled: (previously -m)
-// define( 'WP_TESTS_MULTISITE', true );
-
-// Force known bugs: (previously -f)
-// define( 'WP_TESTS_FORCE_KNOWN_BUGS', true );
-
-// Test with WordPress debug mode on (previously -d)
-// define( 'WP_DEBUG', true );
-
-// ** MySQL settings ** //
-
-// This configuration file will be used by the copy of WordPress being tested.
-// wordpress/wp-config.php will be ignored.
-
-// WARNING WARNING WARNING!
-// wp-test will DROP ALL TABLES in the database named below.
-// DO NOT use a production database or one that is shared with something else.
-
-define( 'DB_NAME', 'putyourdbnamehere' );    // The name of the database
-define( 'DB_USER', 'usernamehere' );     // Your MySQL username
-define( 'DB_PASSWORD', 'yourpasswordhere' ); // ...and password
-define( 'DB_HOST', 'localhost' );    // 99% chance you won't need to change this value
-define( 'DB_CHARSET', 'utf8' );
-define( 'DB_COLLATE', '' );
-
-// You can have multiple installations in one database if you give each a unique prefix
-$table_prefix  = 'wp_';   // Only numbers, letters, and underscores please!
-
-// Change this to localize WordPress.  A corresponding MO file for the
-// chosen language must be installed to wp-content/languages.
-// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
-// to enable German language support.
-define ( 'WPLANG', '' );
-
-define( 'WP_TESTS_DOMAIN', 'example.org' );
-define( 'WP_TESTS_EMAIL', 'admin@example.org' );
-define( 'WP_TESTS_TITLE', 'Test Blog' );
-
-$table_prefix  = 'wp_';
-
-define( 'WP_PHP_BINARY', 'php' );
</del></span></pre></div>
<a id="trunkwptestsconfigsamplephpfromrev872trunkwpconfigsamplephp"></a>
<div class="copfile"><h4>Copied: trunk/wp-tests-config-sample.php (from rev 872, trunk/wp-config-sample.php) (0 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-tests-config-sample.php                                (rev 0)
+++ trunk/wp-tests-config-sample.php        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;?php
+
+/* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */
+define( 'ABSPATH', dirname( __FILE__ ) . '/wordpress/' );
+
+// Test with multisite enabled: (previously -m)
+// define( 'WP_TESTS_MULTISITE', true );
+
+// Force known bugs: (previously -f)
+// define( 'WP_TESTS_FORCE_KNOWN_BUGS', true );
+
+// Test with WordPress debug mode on (previously -d)
+// define( 'WP_DEBUG', true );
+
+// ** MySQL settings ** //
+
+// This configuration file will be used by the copy of WordPress being tested.
+// wordpress/wp-config.php will be ignored.
+
+// WARNING WARNING WARNING!
+// wp-test will DROP ALL TABLES in the database named below.
+// DO NOT use a production database or one that is shared with something else.
+
+define( 'DB_NAME', 'putyourdbnamehere' );    // The name of the database
+define( 'DB_USER', 'usernamehere' );     // Your MySQL username
+define( 'DB_PASSWORD', 'yourpasswordhere' ); // ...and password
+define( 'DB_HOST', 'localhost' );    // 99% chance you won't need to change this value
+define( 'DB_CHARSET', 'utf8' );
+define( 'DB_COLLATE', '' );
+
+// You can have multiple installations in one database if you give each a unique prefix
+$table_prefix  = 'wp_';   // Only numbers, letters, and underscores please!
+
+// Change this to localize WordPress.  A corresponding MO file for the
+// chosen language must be installed to wp-content/languages.
+// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
+// to enable German language support.
+define ( 'WPLANG', '' );
+
+define( 'WP_TESTS_DOMAIN', 'example.org' );
+define( 'WP_TESTS_EMAIL', 'admin@example.org' );
+define( 'WP_TESTS_TITLE', 'Test Blog' );
+
+$table_prefix  = 'wp_';
+
+define( 'WP_PHP_BINARY', 'php' );
</ins></span></pre></div>
<a id="trunkwptestsh"></a>
<div class="delfile"><h4>Deleted: trunk/wptest.sh (874 => 875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wptest.sh        2012-07-03 16:26:26 UTC (rev 874)
+++ trunk/wptest.sh        2012-07-03 17:24:03 UTC (rev 875)
</span><span class="lines">@@ -1,3 +0,0 @@
</span><del>-#!/bin/bash
-# Run the test runner passing all CLI args on
-php wp-test.php $@
</del></span></pre>
</div>
</div>

</body>
</html>