This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
forked from strangerstudios/paid-memberships-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c83cf5
commit 3d35b93
Showing
5 changed files
with
291 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
tests/wpunit/functions/Levels/ChangeMembershipLevelTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace PMPro\Tests\Functions\Levels; | ||
|
||
use PMPro\Test_Support\Factories\PMPro_LevelFactory; | ||
use PMPro\Test_Support\TestCases\TestCase; | ||
|
||
/** | ||
* @group pmpro-functions | ||
* @group pmpro-levels | ||
*/ | ||
class ChangeMembershipLevelTest extends TestCase { | ||
|
||
/** | ||
* @covers ::pmpro_changeMembershipLevel() | ||
*/ | ||
public function test_pmpro_changeMembershipLevel_is_false_with_empty_level_and_invalid_user() { | ||
$this->assertFalse( pmpro_changeMembershipLevel( null ) ); | ||
$this->assertFalse( pmpro_changeMembershipLevel( 0 ) ); | ||
$this->assertFalse( pmpro_changeMembershipLevel( '' ) ); | ||
$this->assertFalse( pmpro_changeMembershipLevel( [] ) ); | ||
} | ||
|
||
/** | ||
* @covers ::pmpro_changeMembershipLevel() | ||
*/ | ||
public function test_pmpro_changeMembershipLevel_is_null_with_invalid_level_and_no_user_and_valid_current_user() { | ||
$user_id = $this->factory->user->create(); | ||
|
||
wp_set_current_user( $user_id ); | ||
|
||
$this->assertNull( pmpro_changeMembershipLevel( null ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( 0 ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( '' ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( [] ) ); | ||
} | ||
|
||
/** | ||
* @covers ::pmpro_changeMembershipLevel() | ||
*/ | ||
public function test_pmpro_changeMembershipLevel_is_null_with_invalid_level_and_valid_user() { | ||
$user_id = $this->factory()->user->create(); | ||
|
||
$this->assertNull( pmpro_changeMembershipLevel( null, $user_id ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( 0, $user_id ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( '', $user_id ) ); | ||
$this->assertNull( pmpro_changeMembershipLevel( [], $user_id ) ); | ||
} | ||
|
||
/** | ||
* @covers ::pmpro_changeMembershipLevel() | ||
*/ | ||
public function test_pmpro_changeMembershipLevel_is_true_with_valid_level_and_valid_user() { | ||
$level_id = $this->factory()->pmpro_level->create(); | ||
$user_id = $this->factory()->user->create(); | ||
|
||
$this->assertTrue( pmpro_changeMembershipLevel( $level_id, $user_id ) ); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/wpunit/functions/Levels/GetMembershipLevelsForUserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace PMPro\Tests\Functions\Levels; | ||
|
||
use PMPro\Test_Support\Factories\PMPro_LevelFactory; | ||
use PMPro\Test_Support\TestCases\TestCase; | ||
|
||
/** | ||
* @group pmpro-functions | ||
* @group pmpro-levels | ||
*/ | ||
class GetMembershipLevelsForUserTest extends TestCase { | ||
|
||
/** | ||
* @covers ::pmpro_getMembershipLevelsForUser() | ||
* | ||
* @param null $user_id | ||
* @param bool $include_inactive | ||
* @param bool $expects | ||
*/ | ||
public function test_pmpro_getMembershipLevelsForUser( $user_id = null, $include_inactive = false, $expects = false ) { | ||
$this->assertFalse( pmpro_getMembershipLevelsForUser( null, false ) ); | ||
} | ||
} |
Oops, something went wrong.