Skip to content

Commit

Permalink
Move logout/redirect to method in the main class -- more realistic.
Browse files Browse the repository at this point in the history
  • Loading branch information
convissor committed Nov 8, 2012
1 parent 9fdfccb commit d851466
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
14 changes: 12 additions & 2 deletions oop-plugin-template-solution.php
Expand Up @@ -7,7 +7,7 @@
* object-oriented programming practices.
*
* Plugin URI: http://wordpress.org/extend/plugins/oop-plugin-template-solution/
* Version: 1.0.2
* Version: 1.1.0
* (Remember to change the VERSION constant, below, as well!)
* Author: Daniel Convissor
* Author URI: http://www.analysisandsolutions.com/
Expand Down Expand Up @@ -49,7 +49,7 @@ class oop_plugin_template_solution {
/**
* This plugin's version
*/
const VERSION = '1.0.2';
const VERSION = '1.1.0';

/**
* This plugin's table name prefix
Expand Down Expand Up @@ -197,6 +197,16 @@ public function wp_login($user_name, $user) {
* ===== INTERNAL METHODS ====
*/

/**
* Log the user out and send them to the lost password page
*
* This is here solely for demonstration of unit testing.
*/
protected function force_retrieve_pw() {
wp_logout();
wp_redirect(wp_login_url() . '?action=retrievepassword');
}

/**
* Obtains the email addresses the notifications should go to
* @return string
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Expand Up @@ -185,6 +185,10 @@ the `.pot`, `.po` and `.mo` files:

== Changelog ==

= 1.1.0 (2012-11-08) =
* Move the `wp_logout()` and `wp_redirect()` calls from direct calls in the
test method to a method in the tested class instead.

= 1.0.2 (2012-11-05) =
* Explain why can't use PHPUnit's @expectedException functionality.

Expand Down
5 changes: 1 addition & 4 deletions tests/LoginTest.php
Expand Up @@ -82,10 +82,7 @@ public function test_redirect() {
$this->expected_errors($expected_error);
self::$location_expected = wp_login_url() . '?action=retrievepassword';

// For demonstration purposes only. In the real world, the logout
// and redirect would be triggred by some method in your plugin.
wp_logout();
wp_redirect(wp_login_url() . '?action=retrievepassword');
self::$o->force_retrieve_pw();

$this->assertTrue($this->were_expected_errors_found(),
"Expected error not found: '$expected_error'");
Expand Down

0 comments on commit d851466

Please sign in to comment.