Permalink
Browse files

More user friendly handling of activation errors

  • Loading branch information...
1 parent 862eb54 commit 2c608c5093ffb98b201cc9dd2c72def2bfbcb498 @toppa committed Sep 25, 2011
Showing with 30 additions and 26 deletions.
  1. +1 −1 WpSimpleTest.php
  2. +9 −7 readme.txt
  3. +20 −18 start.php
View
@@ -16,7 +16,7 @@ class WpSimpleTest {
'passes' => '');
private $fullTestFilePath;
- function __construct(ToppaFunctionsFacade &$functionsFacade) {
+ public function __construct(ToppaFunctionsFacade $functionsFacade) {
$this->functionsFacade = $functionsFacade;
}
View
@@ -1,10 +1,10 @@
=== SimpleTest for WordPress ===
-Contributors: Mike Toppa
+Contributors: toppa
Donate link: http://www.toppa.com/simpletest-for-wordpress/
Tags: unit test, integration test, plugin testing, testing, test, TDD, SimpleTest
Requires at least: 3.0
Tested up to: 3.0
-Stable tag: 1.0.1
+Stable tag: 1.0.2
Enables unit testing and integration testing for WordPress plugins, using SimpleTest
@@ -49,11 +49,13 @@ The example shortcode above will work. It runs the unit tests I wrote for the pl
== Changelog ==
-= 1.0 =
-
-* First version
-
-= 1.0.1
+= 1.0.2 =
+* More user friendly handling of activation errors
+* Added .pot language translation file
+= 1.0.1 =
* Added activation function, to check all dependencies are met
* Does not run if dependencies are not met
+
+= 1.0 =
+* First version
View
@@ -4,40 +4,42 @@
Plugin URI: http://www.toppa.com/simpletest-for-wordpress
Description: Enables unit and integration testing for WordPress plugins, using SimpleTest
Author: Michael Toppa
-Version: 1.0
+Version: 1.0.2
Author URI: http://www.toppa.com
*/
-$autoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php';
+$wpSimpleTestAutoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php';
+register_activation_hook(__FILE__, 'wpSimpleTestActivate');
+load_plugin_textdomain('wp-simpletest', false, basename(dirname(__FILE__)) . '/languages/');
-if (file_exists($autoLoaderPath) && function_exists('spl_autoload_register')) {
- require_once($autoLoaderPath);
- $toppaAutoLoader = new ToppaAutoLoaderWp('/toppa-plugin-libraries-for-wordpress');
+if (file_exists($wpSimpleTestAutoLoaderPath)) {
+ require_once($wpSimpleTestAutoLoaderPath);
+ $wpSimpleTestToppaAutoLoader = new ToppaAutoLoaderWp('/toppa-plugin-libraries-for-wordpress');
$wpSimpleTestAutoLoader = new ToppaAutoLoaderWp('/simpletest-for-wordpress');
$functionsFacade = new ToppaFunctionsFacadeWp();
$simpleTest = new WpSimpleTest($functionsFacade);
$simpleTest->run();
}
-else {
- // do nothing if dependencies are not met
-}
-
-register_activation_hook(__FILE__, 'wpSimpleTestActivate');
-
function wpSimpleTestActivate() {
- $autoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php';
+ $wpSimpleTestAutoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php';
- if (!file_exists($autoLoaderPath)) {
- trigger_error('You must also install the "Toppa Plugin Libraries for WordPress" plugin to use SimpleTest for WordPress (this is not actually a PHP error)', E_USER_ERROR);
+ if (!file_exists($wpSimpleTestAutoLoaderPath)) {
+ $message = __('To activate SimpleTest for WordPress you need to first install', 'wp-simpletest')
+ . ' <a href="http://wordpress.org/extend/plugins/toppa-plugin-libraries-for-wordpress/">Toppa Plugins Libraries for WordPress</a>';
+ wpSimpleTestCancelActivation($message);
}
- if (!function_exists('spl_autoload_register')) {
- trigger_error('You must have at least PHP 5.1.2 to use SimpleTest for WordPress (this is not actually a PHP error)', E_USER_ERROR);
+ elseif (!function_exists('spl_autoload_register')) {
+ wpSimpleTestCancelActivation(__('You must have at least PHP 5.1.2 to use SimpleTest for WordPress', 'wp-simpletest'));
}
- if (version_compare(get_bloginfo('version'), '3.0', '<')) {
- trigger_error('You must have at least WordPress 3.0 to use SimpleTest for WordPress (this is not actually a PHP error)', E_USER_ERROR);
+ elseif (version_compare(get_bloginfo('version'), '3.0', '<')) {
+ wpSimpleTestCancelActivation(__('You must have at least WordPress 3.0 to use SimpleTest for WordPress', 'wp-simpletest'));
}
}
+function wpSimpleTestCancelActivation($message) {
+ deactivate_plugins(basename(__FILE__));
+ wp_die($message);
+}

0 comments on commit 2c608c5

Please sign in to comment.