diff --git a/tests/phpunit/tests/ThemesScreens/ThemesScreens_ConstructTest.php b/tests/phpunit/tests/ThemesScreens/ThemesScreens_ConstructTest.php new file mode 100644 index 0000000..fb3b8b6 --- /dev/null +++ b/tests/phpunit/tests/ThemesScreens/ThemesScreens_ConstructTest.php @@ -0,0 +1,68 @@ +assertIsInt( has_action( $hook, [ $themes_screens, $method ] ) ); + } + + /** + * Test that hooks are not added when API rewriting is disabled. + * + * @dataProvider data_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 ); + + $themes_screens = new AspireUpdate\Themes_Screens(); + $this->assertFalse( has_action( $hook, [ $themes_screens, $method ] ) ); + } + + /** + * Data provider. + * + * @return array[] + */ + public function data_hooks_and_methods() { + return [ + 'admin_enqueue_scripts -> admin_enqueue_scripts' => [ + 'hook' => 'admin_enqueue_scripts', + 'method' => 'admin_enqueue_scripts', + ], + 'load-theme-install.php -> redirect_to_theme_install' => [ + 'hook' => 'load-theme-install.php', + 'method' => 'redirect_to_theme_install', + ], + ]; + } +}