WordPress.org

Plugin Directory

Changeset 559521


Ignore:
Timestamp:
06/17/12 21:34:00 (22 months ago)
Author:
toppa
Message:

version 1.1

Location:
simpletest-for-wordpress/trunk
Files:
141 added
5 edited

Legend:

Unmodified
Added
Removed
  • simpletest-for-wordpress/trunk/WpSimpleTest.php

    r443175 r559521  
    11<?php 
    22 
    3 // the simpleTest class files names don't match the class names, 
    4 // so we can't use the autoloader 
    5 require_once('simpletest/unit_tester.php'); 
    6 require_once('simpletest/reporter.php'); 
    7 require_once('simpletest/mock_objects.php'); 
     3require_once 'simpletest/unit_tester.php'; 
     4require_once 'simpletest/mock_objects.php'; 
    85 
    96class WpSimpleTest { 
    10     private $version = '1.0.2'; 
     7    private $version = '1.1'; 
    118    private $cssFileName = 'simpletest.css'; 
    129    private $functionsFacade; 
     
    2219 
    2320    public function run() { 
     21        add_action('wp_enqueue_scripts', array($this, 'enqueueStyle')); 
     22        add_shortcode('simpletest', array($this, 'handleShortcode')); 
     23    } 
     24 
     25    public function enqueueStyle() { 
    2426        $cssUrl = $this->functionsFacade->getUrlForCustomizableFile($this->cssFileName, __FILE__); 
    2527        wp_enqueue_style('simpletest_css', $cssUrl, false, $this->version); 
    26         add_shortcode('simpletest', array($this, 'handleShortcode')); 
    2728    } 
    2829 
     
    3233            $this->setShortcode($userShortcode); 
    3334            $this->confirmTestFileExists($this->shortcode['path']); 
    34             $groupTest = new GroupTest($this->shortcode['name']); 
     35            $testSuite = new TestSuite($this->shortcode['name']); 
    3536            $reporter = new WpSimpleTestReporter($this->shortcode['passes']); 
    36             $testResults = $this->runTests($groupTest, $reporter); 
     37            $testResults = $this->runTests($testSuite, $reporter); 
    3738        } 
    3839 
     
    7071    } 
    7172 
    72     public function runTests(GroupTest $groupTest, WpSimpleTestReporter $reporter) { 
     73    public function runTests(TestSuite $testSuite, WpSimpleTestReporter $reporter) { 
    7374        ob_start(); 
    74         $groupTest->addTestFile($this->fullTestFilePath); 
    75         $groupTest->run($reporter); 
     75        $testSuite->addFile($this->fullTestFilePath); 
     76        $testSuite->run($reporter); 
    7677        $testResults = ob_get_contents(); 
    7778        ob_end_clean(); 
  • simpletest-for-wordpress/trunk/WpSimpleTestReporter.php

    r396904 r559521  
    55    function __construct($showPasses) { 
    66        $this->showPasses = $showPasses; 
    7         parent::HtmlReporter('UTF-8'); 
     7        parent::__construct('UTF-8'); 
    88    } 
    99 
  • simpletest-for-wordpress/trunk/readme.txt

    r443167 r559521  
    44Tags: unit test, integration test, plugin testing, testing, test, TDD, SimpleTest 
    55Requires at least: 3.0 
    6 Tested up to: 3.0 
    7 Stable tag: 1.0.2 
     6Tested up to: 3.4 
     7Stable tag: 1.1 
     8License: GPLv2 or later 
    89 
    910Enables unit testing and integration testing for WordPress plugins, using SimpleTest 
     
    1314**Overview** 
    1415 
    15 SimpleTest for WordPress is a tool for WordPress plugin developers who want to create and run automated tests for their plugins. It includes [SimpleTest 1.0.1](http://www.simpletest.org/) and uses a shortcode to let you run unit tests on WordPress plugins, and see the results in a WordPress page. Since it runs within WordPress, you can also do integration testing of plugins (that is, custom WordPress functions used in the plugins will work correctly when the tests are run). 
     16SimpleTest for WordPress is a tool for WordPress plugin developers who want to create and run automated tests for their plugins. It includes [SimpleTest 1.1](http://www.simpletest.org/) and uses a shortcode to let you run unit tests on WordPress plugins, and see the results in a WordPress page. Since it runs within WordPress, you can also do integration testing of plugins (that is, custom WordPress functions used in the plugins will work correctly when the tests are run). 
    1617 
    1718**Installation of [Toppa Plugin Libraries for WordPress](http://wordpress.org/extend/plugins/toppa-plugin-libraries-for-wordpress/) is required for this plugin. Please download and install it first.** 
     
    5051== Changelog == 
    5152 
     53= 1.1 = 
     54* Upgraded the included version of SimpleTest to the current version (1.1.0) 
     55* Updated WordPress test runner and HTML report to use SimpleTest 1.1.0 
     56* Check system requirements at admin_init (instead of plugin activation) 
     57* Improved included sample tests 
     58* Follow correct WordPress procedure for including stylesheet 
     59 
    5260= 1.0.2 = 
    5361* More user friendly handling of activation errors 
  • simpletest-for-wordpress/trunk/start.php

    r443167 r559521  
    55Description: Enables unit and integration testing for WordPress plugins, using SimpleTest 
    66Author: Michael Toppa 
    7 Version: 1.0.2 
     7Version: 1.1 
    88Author URI: http://www.toppa.com 
     9License: GPLv2 or later 
    910*/ 
    1011 
    1112$wpSimpleTestAutoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php'; 
    12 register_activation_hook(__FILE__, 'wpSimpleTestActivate'); 
     13add_action('admin_init', 'wpSimpleTestRuntimeChecks'); 
    1314load_plugin_textdomain('wp-simpletest', false, basename(dirname(__FILE__)) . '/languages/'); 
    1415 
     
    2223} 
    2324 
    24 function wpSimpleTestActivate() { 
    25     $wpSimpleTestAutoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php'; 
     25function wpSimpleTestRuntimeChecks() { 
     26    $status = wpSimpleTestActivationChecks(); 
    2627 
    27     if (!file_exists($wpSimpleTestAutoLoaderPath)) { 
    28         $message = __('To activate SimpleTest for WordPress you need to first install', 'wp-simpletest') 
    29             . ' <a href="http://wordpress.org/extend/plugins/toppa-plugin-libraries-for-wordpress/">Toppa Plugins Libraries for WordPress</a>'; 
    30         wpSimpleTestCancelActivation($message); 
     28    if (is_string($status)) { 
     29        wpSimpleTestCancelActivation($status); 
     30        return null; 
    3131    } 
    3232 
    33     elseif (!function_exists('spl_autoload_register')) { 
    34         wpSimpleTestCancelActivation(__('You must have at least PHP 5.1.2 to use SimpleTest for WordPress', 'wp-simpletest')); 
     33    return null; 
     34} 
     35 
     36function wpSimpleTestActivationChecks() { 
     37    $autoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php'; 
     38    $toppaLibsVersion = get_option('toppaLibsVersion'); 
     39 
     40    if (!file_exists($autoLoaderPath) || !$toppaLibsVersion || version_compare($toppaLibsVersion, '1.3.3', '<')) { 
     41        return __('To activate SimpleTest for WordPress you need to have the current version of', 'wp-simpletest') 
     42            . ' <a href="plugin-install.php?tab=plugin-information&plugin=toppa-plugin-libraries-for-wordpress">Toppa Plugins Libraries for WordPress</a>. ' 
     43            . __('Click this link to view details, and then click the "Install Now" button to get the current version. Then you can activate Shashin.', 'wp-simpletest'); 
    3544    } 
    3645 
    37     elseif (version_compare(get_bloginfo('version'), '3.0', '<')) { 
    38         wpSimpleTestCancelActivation(__('You must have at least WordPress 3.0 to use SimpleTest for WordPress', 'wp-simpletest')); 
     46    if (!function_exists('spl_autoload_register')) { 
     47        return __('SimpleTest for WordPress not activated. You must have at least PHP 5.1.2 to use SimpleTest for WordPress', 'wp-simpletest'); 
    3948    } 
     49 
     50    if (version_compare(get_bloginfo('version'), '3.0', '<')) { 
     51        return __('SimpleTest for WordPress not activated. You must have at least WordPress 3.0 to use SimpleTest for WordPress', 'wp-simpletest'); 
     52    } 
     53 
     54    return true; 
    4055} 
    4156 
    4257function wpSimpleTestCancelActivation($message) { 
    43     deactivate_plugins(basename(__FILE__)); 
     58    deactivate_plugins('simpletest-for-wordpress/start.php', true); 
    4459    wp_die($message); 
    4560} 
  • simpletest-for-wordpress/trunk/tests/UnitWpSimpleTest.php

    r396904 r559521  
    11<?php 
    22 
    3 require_once(dirname(__FILE__) . '/../../toppa-plugin-libraries-for-wordpress/ToppaFunctions.php'); 
    43require_once(dirname(__FILE__) . '/../../toppa-plugin-libraries-for-wordpress/ToppaFunctionsFacadeWp.php'); 
    5 require_once(dirname(__FILE__) . '/../WpSimpleTest.php'); 
    64Mock::generate('ToppaFunctionsFacadeWp'); 
    75 
    86class UnitWpSimpleTest extends UnitTestCase { 
    97    private $functionsFacade; 
    10     private $shortcodeNoPath = array('name' => 'Test Results', 'path' => '', 'passes' => 'n'); 
    11     private $shortcodeBadPath = array('path' => '/nowhere'); 
    12     private $shortcodeGoodPath = array('name' => 'Wp Simpletest', 'path' => '/wp-simpletest/tests', 'passes' => 'y'); 
    138 
    149    public function __construct() { 
    15         $this->UnitTestCase(); 
    1610    } 
    1711 
     
    2418        $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
    2519        $expectedShortcodeNoPath = array('name' => 'Test Results', 'path' => '', 'passes' => 'n'); 
    26         $wpSimpleTest->setShortcode($this->shortcodeNoPath); 
     20        $shortcodeNoPath = array('name' => 'Test Results', 'path' => '', 'passes' => 'n'); 
     21        $wpSimpleTest->setShortcode($shortcodeNoPath); 
    2722        $this->assertEqual($expectedShortcodeNoPath, $wpSimpleTest->getShortcode()); 
    2823    } 
     
    3126        $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
    3227        $expectedShortcodeBadPath = array('name' => 'Test Results', 'path' => '/nowhere', 'passes' => ''); 
    33         $wpSimpleTest->setShortcode($this->shortcodeBadPath); 
     28        $shortcodeBadPath = array('path' => '/nowhere'); 
     29        $wpSimpleTest->setShortcode($shortcodeBadPath); 
    3430        $this->assertEqual($expectedShortcodeBadPath, $wpSimpleTest->getShortcode()); 
    3531    } 
     
    3834        $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
    3935        $expectedShortcodeGoodPath = array('name' => 'Wp Simpletest', 'path' => '/wp-simpletest/tests', 'passes' => 'y'); 
    40         $wpSimpleTest->setShortcode($this->shortcodeGoodPath); 
     36        $shortcodeGoodPath = array('name' => 'Wp Simpletest', 'path' => '/wp-simpletest/tests', 'passes' => 'y'); 
     37        $wpSimpleTest->setShortcode($shortcodeGoodPath); 
    4138        $this->assertEqual($expectedShortcodeGoodPath, $wpSimpleTest->getShortcode()); 
    4239    } 
     
    4643            $this->functionsFacade->setReturnValue('checkFileExists', false); 
    4744            $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
    48             $wpSimpleTest->confirmTestFileExists($this->shortcodeNoPath['path']); 
     45            $wpSimpleTest->confirmTestFileExists(''); 
    4946        } 
    5047 
     
    5754        try { 
    5855            $this->functionsFacade->setReturnValue('checkFileExists', false); 
    59             $wpSimpleTest = new WpSimpleTest($this->functionsFacade, $this->hooksFacade); 
    60             $wpSimpleTest->confirmTestFileExists($this->shortcodeBadPath['path']); 
     56            $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
     57            $wpSimpleTest->confirmTestFileExists('/nowhere'); 
    6158        } 
    6259 
     
    6966        try { 
    7067            $this->functionsFacade->setReturnValue('checkFileExists', true); 
    71             $wpSimpleTest = new WpSimpleTest($this->functionsFacade, $this->hooksFacade); 
    72             $this->assertTrue($wpSimpleTest->confirmTestFileExists($this->shortcodeGoodPath['path'])); 
     68            $wpSimpleTest = new WpSimpleTest($this->functionsFacade); 
     69            $this->assertTrue($wpSimpleTest->confirmTestFileExists('/wp-simpletest/tests')); 
    7370 
    7471        } 
Note: See TracChangeset for help on using the changeset viewer.