Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce and implement AdminSettings_UnitTestCase #213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@

<!-- Enforce short syntax arrays. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- Exclude test classes from naming conventions. -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
</rule>
</ruleset>
3 changes: 3 additions & 0 deletions tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ function _manually_load_plugin() {

// Start up the WP testing environment.
require "{$_tests_dir}/includes/bootstrap.php";

// Load unit test abstract classes.
require __DIR__ . '/includes/AdminSettings_UnitTestCase.php';
25 changes: 25 additions & 0 deletions tests/phpunit/includes/AdminSettings_UnitTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Abstract base test class for \AspireUpdate\Admin_Settings.
*
* All \AspireUpdate\Admin_Settings unit tests should inherit from this class.
*/
abstract class AdminSettings_UnitTestCase extends WP_UnitTestCase {
/**
* The Name of the Option.
*
* @var string
*/
protected static $option_name = 'aspireupdate_settings';

/**
* Deletes settings before each test runs.
*
* @return void
*/
public function set_up() {
parent::set_up();

delete_site_option( self::$option_name );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers \AspireUpdate\Admin_Settings::get_setting
*/
class AdminSettings_GetSettingTest extends WP_UnitTestCase {
class AdminSettings_GetSettingTest extends AdminSettings_UnitTestCase {
/**
* Test that the default 'api_host' value is retrieved.
*
Expand Down