Plugin Directory

Changeset 337135


Ignore:
Timestamp:
01/25/2011 06:07:18 PM (15 years ago)
Author:
aaires
Message:

bundled phpunit

Location:
wp-unit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-unit/trunk/WPUnit.php

    r331858 r337135  
    44Description: Unit Test Development
    55Version: 1.0
    6 Author: WidgiLabs Team
     6Author: WidgiLabs team
    77Author URI: http://widgilabs.com
    88/usr/local/php5/bin:/Users/aaires/Projects/android/sdk:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/bin:/sw/bin:/sw/sbin:/usr/local/bin
     
    6767        $result = new PHPUnit_Framework_TestResult;
    6868        $printer = new PHPUnit_TextUI_ResultPrinter;
    69         $result = wptest_run_tests($classes, @$opts['t']); 
    70        
    71         wptest_print_result($result);
     69        list ($result, $printer) = wptest_run_tests($classes, @$opts['t']);
     70       
     71        wptest_print_result($printer,$result);
    7272   
    7373    }
     
    7575}
    7676
     77
     78
     79   
     80
    7781   
    7882/**********************************************Wordpress Stuff ****************************/
    79 // Taken from wp-testlib
    80 
    8183// simple functions for loading and running tests
    8284/*This was retrieve from the unit test framework done by Wordpress*/
     
    139141   
    140142    require_once('PHPUnit/TextUI/ResultPrinter.php');
    141 
    142     return $suite->run($result);
    143 }
    144 
    145 /*end WordPress stuff*/
    146 
    147 // Parse the results
    148 function wptest_print_result(PHPUnit_Framework_TestResult $result) {
     143   
     144    $printer = new PHPUnit_TextUI_ResultPrinter(NULL,true,true);
     145    $result->addListener($printer);
     146
     147    return array($suite->run($result), $printer);
     148}
     149
     150function wptest_print_result(PHPUnit_TextUI_ResultPrinter $printer, PHPUnit_Framework_TestResult $result) {
    149151
    150152       
     
    272274}
    273275
     276/**
     277 * Return and/or display the time from the page start to when function is called.
     278 *
     279 * You can get the results and print them by doing:
     280 * <code>
     281 * $nTimePageTookToExecute = timer_stop();
     282 * echo $nTimePageTookToExecute;
     283 * </code>
     284 *
     285 * Or instead, you can do:
     286 * <code>
     287 * timer_stop(1);
     288 * </code>
     289 * which will do what the above does. If you need the result, you can assign it to a variable, but
     290 * most cases, you only need to echo it.
     291 *
     292 * @since 0.71
     293 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
     294 * @global int $timeend  Seconds and Microseconds added together from when function is called
     295 *
     296 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
     297 * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
     298 * @return float The "second.microsecond" finished time calculation
     299 */
     300//function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
     301//  global $timestart, $timeend;
     302//  $mtime = microtime();
     303//  $mtime = explode( ' ', $mtime );
     304//  $timeend = $mtime[1] + $mtime[0];
     305//  $timetotal = $timeend - $timestart;
     306//  $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
     307//  if ( $display )
     308//      echo $r;
     309//  return $r;
     310//}
     311/*end WordPress stuff*/
     312
    274313
    275314
  • wp-unit/trunk/readme.txt

    r331858 r337135  
    44Tags: unit-testing, phpunit
    55Requires at least: 3.0
    6 Tested up to: 3.0
    7 Stable tag: 1.1
     6Tested up to: 3.0.4
     7Stable tag: 2.0
    88
    99== Description ==
    1010
    1111Enables you to create unit tests for your plugins, run and check the results in a centralized way.
    12 It depends on phpunit so you must install it before you use this plugin.
     12It uses phpunit.
    1313
    1414Its based on the WordPress automated system but distributed as a plugin. Also it does not require a new database and a new configuration file so when you create your unit tests pay special attention to your database access so you keep a consistent database.
     
    3131== Changelog ==
    3232
    33 == Upgrade Notice ==
     331.2 Bundle phpunit.
     34
     351.1 Initial version
     36
     37== Upgrade Notice ==
     38
     39None.
    3440
    3541== Screenshots ==
    3642
    37 
     43None.
Note: See TracChangeset for help on using the changeset viewer.