-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for the main plugin class
- Loading branch information
Showing
3 changed files
with
56 additions
and
21 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 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,55 @@ | ||
<?php | ||
/** | ||
* Class Test_Starter_Plugin | ||
* | ||
* @package Starter_Plugin | ||
*/ | ||
|
||
/** | ||
* Sample test case. | ||
*/ | ||
class Test_Starter_Plugin extends WP_UnitTestCase { | ||
public function set_up() { | ||
parent::set_up(); | ||
|
||
// Mock that we're in WP Admin context. | ||
// See https://wordpress.stackexchange.com/questions/207358/unit-testing-in-the-wordpress-backend-is-admin-is-true | ||
set_current_screen( 'edit-post' ); | ||
|
||
$this->starter_plugin = new Starter_Plugin(); | ||
} | ||
|
||
public function tear_down() { | ||
parent::tear_down(); | ||
} | ||
|
||
public function test_has_correct_token() { | ||
$has_correct_token = ( 'starter-plugin' === $this->starter_plugin->token ); | ||
|
||
$this->assertTrue( $has_correct_token ); | ||
} | ||
|
||
public function test_has_admin_interface() { | ||
$has_admin_interface = ( is_a( $this->starter_plugin->admin, 'Starter_Plugin_Admin' ) ); | ||
|
||
$this->assertTrue( $has_admin_interface ); | ||
} | ||
|
||
public function test_has_settings_interface() { | ||
$has_settings_interface = ( is_a( $this->starter_plugin->settings, 'Starter_Plugin_Settings' ) ); | ||
|
||
$this->assertTrue( $has_settings_interface ); | ||
} | ||
|
||
public function test_has_post_types() { | ||
$has_post_types = ( 0 < count( $this->starter_plugin->post_types ) ); | ||
|
||
$this->assertTrue( $has_post_types ); | ||
} | ||
|
||
public function test_has_load_plugin_textdomain() { | ||
$has_load_plugin_textdomain = ( is_int( has_action( 'init', [ $this->starter_plugin, 'load_plugin_textdomain' ] ) ) ); | ||
|
||
$this->assertTrue( $has_load_plugin_textdomain ); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.