diff --git a/tests/phpunit/tests/PluginsScreens/PluginsScreens_ConstructTest.php b/tests/phpunit/tests/PluginsScreens/PluginsScreens_ConstructTest.php new file mode 100644 index 0000000..6e2eb89 --- /dev/null +++ b/tests/phpunit/tests/PluginsScreens/PluginsScreens_ConstructTest.php @@ -0,0 +1,63 @@ +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', + ], + ]; + } +}