Last active
April 5, 2022 18:32
-
-
Save Shelob9/76519a0f6f3f8ad3e77d670104d9e66f to your computer and use it in GitHub Desktop.
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
<?php | |
namespace Something\Tests\Integration; | |
use PHPUnit\Framework\TestCase; | |
use Something\Shortcode; | |
/** | |
* These tests make sure that nothing is super wrong with our code. | |
*/ | |
class ShortCodeTest extends \WP_UnitTestCase { | |
/** | |
* Make sure the the short code callback outputs HTML when user is logged in. | |
* | |
* If this makes no errors, that's good, but still needs manual QA | |
* If it fails, something is wrong. | |
*/ | |
public function testShortcodeWorksWithUserLoggedIn() | |
{ | |
//Create a user | |
$user = get_user_by('ID',self::factory()->user->create()); | |
//Test shortcode class with logged in user | |
$obj = new Shortcode($user); | |
$this->assertNotEmpty( $obj->callback() ); | |
} | |
/** | |
* Make sure the the short code callback outputs HTML when user is NOT logged in | |
* | |
* If this makes no errors, that's good, but still needs manual QA | |
* If it fails, something is wrong. | |
*/ | |
public function testShortcodeWorksWithUserNotLoggedIn() | |
{ | |
//Fake logged out state | |
$user = new \WP_User(); | |
$user->ID = 0; | |
//Create shortcode class, and test output | |
$obj = new Shortcode($user); | |
$this->assertNotEmpty( $obj->callback() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment