diff --git a/src/plugins-tab/application/plugins-list-handler.php b/src/plugins-tab/application/plugins-list-handler.php deleted file mode 100644 index e09f546b9a3..00000000000 --- a/src/plugins-tab/application/plugins-list-handler.php +++ /dev/null @@ -1,73 +0,0 @@ -detector = $detector; - } - - /** - * Filters the plugins list to add a 'yoast' group when 2+ Yoast plugins are installed. - * - * @param array>> $plugins The plugins list keyed by status. - * - * @return array>> The filtered plugins list. - */ - public function filter_plugins_list( $plugins ) { - if ( ! \is_array( $plugins ) || ! isset( $plugins['all'] ) ) { - return $plugins; - } - - $yoast_plugins = []; - foreach ( $plugins['all'] as $plugin_file => $plugin_data ) { - if ( $this->detector->is_yoast_plugin( $plugin_data ) ) { - $yoast_plugins[ $plugin_file ] = $plugin_data; - } - } - - if ( \count( $yoast_plugins ) < Plugin_Detector::MINIMUM_FOR_TAB ) { - return $plugins; - } - - $plugins['yoast'] = $yoast_plugins; - - return $plugins; - } - - /** - * Returns the status text for the Yoast plugins tab. - * - * @param string $text The current status text. - * @param int $count The number of plugins with this status. - * @param string $type The status type slug. - * - * @return string The status text. - */ - public function get_status_text( $text, $count, $type ) { - if ( $type !== 'yoast' ) { - return $text; - } - - return \_nx( 'Yoast', 'Yoast', $count, 'plugin status', 'wordpress-seo' ); - } -} diff --git a/src/plugins-tab/domain/plugin-detector.php b/src/plugins-tab/domain/plugin-detector.php deleted file mode 100644 index af514927c78..00000000000 --- a/src/plugins-tab/domain/plugin-detector.php +++ /dev/null @@ -1,39 +0,0 @@ - $plugin_data The plugin data array. - * - * @return bool Whether the plugin is a Yoast plugin. - */ - public function is_yoast_plugin( array $plugin_data ): bool { - if ( ! isset( $plugin_data['AuthorName'] ) || ! \is_string( $plugin_data['AuthorName'] ) ) { - return false; - } - - return \str_contains( $plugin_data['AuthorName'], self::AUTHOR_IDENTIFIER ); - } -} diff --git a/src/plugins-tab/user-interface/plugins-tab-integration.php b/src/plugins-tab/user-interface/plugins-tab-integration.php deleted file mode 100644 index 2c22ae6c464..00000000000 --- a/src/plugins-tab/user-interface/plugins-tab-integration.php +++ /dev/null @@ -1,59 +0,0 @@ -handler = $handler; - } - - /** - * Returns the conditionals based on which this loadable should be active. - * - * @return array The conditionals. - */ - public static function get_conditionals(): array { - return [ - Admin_Conditional::class, - ]; - } - - /** - * Registers the hooks for the Yoast plugins tab. - * - * @return void - */ - public function register_hooks(): void { - global $wp_version; - - if ( \version_compare( $wp_version, '7.0-alpha0', '<' ) ) { - return; - } - - \add_filter( 'plugins_list', [ $this->handler, 'filter_plugins_list' ] ); - \add_filter( 'plugins_list_status_text', [ $this->handler, 'get_status_text' ], 10, 3 ); - } -} diff --git a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Abstract_Plugins_List_Handler_Test.php b/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Abstract_Plugins_List_Handler_Test.php deleted file mode 100644 index acc03c27e8c..00000000000 --- a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Abstract_Plugins_List_Handler_Test.php +++ /dev/null @@ -1,45 +0,0 @@ -detector = Mockery::mock( Plugin_Detector::class ); - $this->instance = new Plugins_List_Handler( $this->detector ); - } -} diff --git a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Filter_Plugins_List_Test.php b/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Filter_Plugins_List_Test.php deleted file mode 100644 index 82f628cf3ce..00000000000 --- a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Filter_Plugins_List_Test.php +++ /dev/null @@ -1,128 +0,0 @@ - 'Team Yoast' ]; - $yoast_premium = [ 'AuthorName' => 'Team Yoast' ]; - $other_plugin = [ 'AuthorName' => 'Automattic' ]; - - $plugins = [ - 'all' => [ - 'wordpress-seo/wp-seo.php' => $yoast_free, - 'wordpress-seo-premium/wp-seo-premium.php' => $yoast_premium, - 'jetpack/jetpack.php' => $other_plugin, - ], - ]; - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $yoast_free ) - ->andReturn( true ); - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $yoast_premium ) - ->andReturn( true ); - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $other_plugin ) - ->andReturn( false ); - - $result = $this->instance->filter_plugins_list( $plugins ); - - $this->assertArrayHasKey( 'yoast', $result ); - $this->assertCount( 2, $result['yoast'] ); - $this->assertArrayHasKey( 'wordpress-seo/wp-seo.php', $result['yoast'] ); - $this->assertArrayHasKey( 'wordpress-seo-premium/wp-seo-premium.php', $result['yoast'] ); - } - - /** - * Tests that the yoast key is not added when only 1 Yoast plugin is installed. - * - * @return void - */ - public function test_filter_plugins_list_with_single_yoast_plugin() { - $yoast_free = [ 'AuthorName' => 'Team Yoast' ]; - $other_plugin = [ 'AuthorName' => 'Automattic' ]; - - $plugins = [ - 'all' => [ - 'wordpress-seo/wp-seo.php' => $yoast_free, - 'jetpack/jetpack.php' => $other_plugin, - ], - ]; - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $yoast_free ) - ->andReturn( true ); - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $other_plugin ) - ->andReturn( false ); - - $result = $this->instance->filter_plugins_list( $plugins ); - - $this->assertArrayNotHasKey( 'yoast', $result ); - } - - /** - * Tests that the yoast key is not added when no Yoast plugins are installed. - * - * @return void - */ - public function test_filter_plugins_list_with_no_yoast_plugins() { - $other_plugin = [ 'AuthorName' => 'Automattic' ]; - - $plugins = [ - 'all' => [ - 'jetpack/jetpack.php' => $other_plugin, - ], - ]; - - $this->detector - ->expects( 'is_yoast_plugin' ) - ->with( $other_plugin ) - ->andReturn( false ); - - $result = $this->instance->filter_plugins_list( $plugins ); - - $this->assertArrayNotHasKey( 'yoast', $result ); - } - - /** - * Tests that the plugins list is returned unchanged when 'all' key is missing. - * - * @return void - */ - public function test_filter_plugins_list_without_all_key() { - $plugins = [ - 'active' => [ - 'jetpack/jetpack.php' => [ 'AuthorName' => 'Automattic' ], - ], - ]; - - $result = $this->instance->filter_plugins_list( $plugins ); - - $this->assertArrayNotHasKey( 'yoast', $result ); - $this->assertSame( $plugins, $result ); - } -} diff --git a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Get_Status_Text_Test.php b/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Get_Status_Text_Test.php deleted file mode 100644 index 1d4d2ffa6e2..00000000000 --- a/tests/Unit/Plugins_Tab/Application/Plugins_List_Handler/Get_Status_Text_Test.php +++ /dev/null @@ -1,43 +0,0 @@ -once() - ->with( 'Yoast', 'Yoast', 3, 'plugin status', 'wordpress-seo' ) - ->andReturn( 'Yoast' ); - - $result = $this->instance->get_status_text( '', 3, 'yoast' ); - - $this->assertSame( 'Yoast', $result ); - } - - /** - * Tests that the original text is returned for non-yoast types. - * - * @return void - */ - public function test_get_status_text_for_other_type() { - $result = $this->instance->get_status_text( 'Active', 5, 'active' ); - - $this->assertSame( 'Active', $result ); - } -} diff --git a/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Abstract_Plugin_Detector_Test.php b/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Abstract_Plugin_Detector_Test.php deleted file mode 100644 index a44ff79f214..00000000000 --- a/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Abstract_Plugin_Detector_Test.php +++ /dev/null @@ -1,35 +0,0 @@ -instance = new Plugin_Detector(); - } -} diff --git a/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Is_Yoast_Plugin_Test.php b/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Is_Yoast_Plugin_Test.php deleted file mode 100644 index 4b5086475b0..00000000000 --- a/tests/Unit/Plugins_Tab/Domain/Plugin_Detector/Is_Yoast_Plugin_Test.php +++ /dev/null @@ -1,80 +0,0 @@ - 'Team Yoast' ]; - - $this->assertTrue( $this->instance->is_yoast_plugin( $plugin_data ) ); - } - - /** - * Tests that a plugin co-authored by Team Yoast is detected. - * - * @return void - */ - public function test_is_yoast_plugin_with_co_authored_plugin() { - $plugin_data = [ 'AuthorName' => 'Enrico Battocchi & Team Yoast' ]; - - $this->assertTrue( $this->instance->is_yoast_plugin( $plugin_data ) ); - } - - /** - * Tests that a plugin with multiple authors including Team Yoast is detected. - * - * @return void - */ - public function test_is_yoast_plugin_with_multiple_authors() { - $plugin_data = [ 'AuthorName' => 'Thomas Kräftner, ViktorFroberg, marol87, pekz0r, angrycreative, Team Yoast' ]; - - $this->assertTrue( $this->instance->is_yoast_plugin( $plugin_data ) ); - } - - /** - * Tests that a plugin by another author is not detected. - * - * @return void - */ - public function test_is_not_yoast_plugin_with_other_author() { - $plugin_data = [ 'AuthorName' => 'Automattic' ]; - - $this->assertFalse( $this->instance->is_yoast_plugin( $plugin_data ) ); - } - - /** - * Tests that a plugin with missing AuthorName is not detected. - * - * @return void - */ - public function test_is_not_yoast_plugin_with_missing_author() { - $plugin_data = []; - - $this->assertFalse( $this->instance->is_yoast_plugin( $plugin_data ) ); - } - - /** - * Tests that a plugin with non-string AuthorName is not detected. - * - * @return void - */ - public function test_is_not_yoast_plugin_with_non_string_author() { - $plugin_data = [ 'AuthorName' => 123 ]; - - $this->assertFalse( $this->instance->is_yoast_plugin( $plugin_data ) ); - } -} diff --git a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Abstract_Plugins_Tab_Integration_Test.php b/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Abstract_Plugins_Tab_Integration_Test.php deleted file mode 100644 index 0b1b08c5ef7..00000000000 --- a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Abstract_Plugins_Tab_Integration_Test.php +++ /dev/null @@ -1,45 +0,0 @@ -handler = Mockery::mock( Plugins_List_Handler::class ); - $this->instance = new Plugins_Tab_Integration( $this->handler ); - } -} diff --git a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Get_Conditionals_Test.php b/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Get_Conditionals_Test.php deleted file mode 100644 index 7b034f6be57..00000000000 --- a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Get_Conditionals_Test.php +++ /dev/null @@ -1,29 +0,0 @@ -assertSame( $expected, $this->instance->get_conditionals() ); - } -} diff --git a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Register_Hooks_Test.php b/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Register_Hooks_Test.php deleted file mode 100644 index ffe29b422b8..00000000000 --- a/tests/Unit/Plugins_Tab/User_Interface/Plugins_Tab/Register_Hooks_Test.php +++ /dev/null @@ -1,74 +0,0 @@ -once() - ->with( [ $this->handler, 'filter_plugins_list' ] ); - - Monkey\Filters\expectAdded( 'plugins_list_status_text' ) - ->once() - ->with( [ $this->handler, 'get_status_text' ], 10, 3 ); - - $this->instance->register_hooks(); - } - - /** - * Tests that hooks are registered on WP 7.0 beta. - * - * @return void - */ - public function test_register_hooks_on_wp_70_beta() { - global $wp_version; - $wp_version = '7.0-beta6'; - - Monkey\Filters\expectAdded( 'plugins_list' ) - ->once() - ->with( [ $this->handler, 'filter_plugins_list' ] ); - - Monkey\Filters\expectAdded( 'plugins_list_status_text' ) - ->once() - ->with( [ $this->handler, 'get_status_text' ], 10, 3 ); - - $this->instance->register_hooks(); - } - - /** - * Tests that hooks are not registered on WP below 7.0. - * - * @return void - */ - public function test_register_hooks_on_wp_below_70() { - global $wp_version; - $wp_version = '6.9.1'; - - Monkey\Filters\expectAdded( 'plugins_list' ) - ->never(); - - Monkey\Filters\expectAdded( 'plugins_list_status_text' ) - ->never(); - - $this->instance->register_hooks(); - } -}