Skip to content

Commit

Permalink
Users connector test updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Aug 21, 2020
1 parent ca71f8e commit 41f23f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
4 changes: 0 additions & 4 deletions classes/class-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public function register() {
* Unregister all context hooks
*/
public function unregister() {
if ( ! $this->is_registered ) {
return;
}

foreach ( $this->actions as $action ) {
remove_action( $action, array( $this, 'callback' ), 10, 99 );
}
Expand Down
24 changes: 19 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions tests/tests/connectors/test-class-connector-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function setUp() {

// Make partial of Connector_Users class, with mocked "log" function.
$this->mock = $this->getMockBuilder( Connector_Users::class )
->setMethods( [ 'log' ] )
->setMethods( array( 'log' ) )
->getMock();

$this->mock->register();
Expand Down Expand Up @@ -159,9 +159,11 @@ public function test_callback_set_logged_in_cookie() {
}

public function test_callback_clear_auth_cookie() {
$this->markTestSkipped( 'This test is to be skipped until scenario issue resolved.' );
// Create and authenticate user.
$user_id = self::factory()->user->create( array( 'display_name' => 'TestGuy' ) );
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );

// Expected log calls.
$this->mock->expects( $this->once() )
Expand All @@ -175,12 +177,11 @@ public function test_callback_clear_auth_cookie() {
$this->equalTo( $user_id )
);

// Do stuff.
wp_logout();
// Manually trigger the action to execute callback.
do_action( 'clear_auth_cookie' );

// Check callback test action.
$this->assertFalse( 0 === did_action( 'wp_stream_test_callback_clear_auth_cookie' ) );
$this->assertTrue( 1 === did_action( 'wp_logout' ) );
}

public function test_callback_deleted_user() {
Expand Down

0 comments on commit 41f23f6

Please sign in to comment.