-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
Plugins_Screens::__construct()
. (#220)
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
tests/phpunit/tests/PluginsScreens/PluginsScreens_ConstructTest.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,63 @@ | ||
<?php | ||
/** | ||
* Class PluginsScreens_ConstructTest | ||
* | ||
* @package AspireUpdate | ||
*/ | ||
|
||
/** | ||
* Tests for Plugins_Screens::__construct() | ||
* | ||
* These tests cause constants to be defined. | ||
* They must run in separate processes and must not preserve global state. | ||
* | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
* | ||
* @covers \AspireUpdate\Plugins_Screens::__construct | ||
*/ | ||
class PluginsScreens_ConstructTest extends WP_UnitTestCase { | ||
/** | ||
* Test that hooks are added when API rewriting is enabled. | ||
* | ||
* @dataProvider data_single_site_hooks_and_methods | ||
* | ||
* @string $hook The hook's name. | ||
* @string $method The method to hook. | ||
*/ | ||
public function test_should_add_hooks( $hook, $method ) { | ||
define( 'AP_ENABLE', true ); | ||
|
||
$plugins_screens = new AspireUpdate\Plugins_Screens(); | ||
$this->assertIsInt( has_action( $hook, [ $plugins_screens, $method ] ) ); | ||
} | ||
|
||
/** | ||
* Test that hooks are not added when API rewriting is disabled. | ||
* | ||
* @dataProvider data_single_site_hooks_and_methods | ||
* | ||
* @string $hook The hook's name. | ||
* @string $method The method to hook. | ||
*/ | ||
public function test_should_not_add_hooks( $hook, $method ) { | ||
define( 'AP_ENABLE', false ); | ||
|
||
$plugins_screens = new AspireUpdate\Plugins_Screens(); | ||
$this->assertFalse( has_action( $hook, [ $plugins_screens, $method ] ) ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_single_site_hooks_and_methods() { | ||
return [ | ||
'install_plugins_tabs -> remove_unused_filter_tabs' => [ | ||
'hook' => 'install_plugins_tabs', | ||
'method' => 'remove_unused_filter_tabs', | ||
], | ||
]; | ||
} | ||
} |