diff --git a/src/editors/framework/integrations/news-seo.php b/src/editors/framework/integrations/news-seo.php index 6ad2c5cc77d..d7059dc8511 100644 --- a/src/editors/framework/integrations/news-seo.php +++ b/src/editors/framework/integrations/news-seo.php @@ -19,7 +19,7 @@ class News_SEO implements Integration_Data_Provider_Interface { /** * The constructor. - * + * * @param WPSEO_Addon_Manager $addon_manager The addon manager. */ public function __construct( WPSEO_Addon_Manager $addon_manager ) { diff --git a/tests/Unit/Editors/Framework/Integrations/News_SEO_Test.php b/tests/Unit/Editors/Framework/Integrations/News_SEO_Test.php new file mode 100644 index 00000000000..00bc0f10a6a --- /dev/null +++ b/tests/Unit/Editors/Framework/Integrations/News_SEO_Test.php @@ -0,0 +1,95 @@ +addon_manager = Mockery::mock( WPSEO_Addon_Manager::class ); + $this->instance = new News_SEO( $this->addon_manager ); + } + + /** + * Tests the is_enabled method. + * + * @dataProvider data_provider_is_enabled + * + * @param bool $news_seo_enabled If the news plugin is enabled. + * @param bool $expected The expected outcome. + * + * @return void + */ + public function test_is_enabled( + bool $news_seo_enabled, + bool $expected + ) { + + $this->addon_manager + ->expects( 'get_plugin_file' ) + ->times( 3 ) + ->with( 'yoast-seo-news' ) + ->andReturn( 'wpseo-news/wpseo-news.php' ); + + Monkey\Functions\expect( 'is_plugin_active' ) + ->times( 3 ) + ->with( 'wpseo-news/wpseo-news.php' ) + ->andReturn( $news_seo_enabled ); + + $is_woo_seo_active = $this->instance->is_enabled(); + + $this->assertSame( $expected, $is_woo_seo_active ); + $this->assertSame( [ 'isNewsSeoActive' => $is_woo_seo_active ], $this->instance->to_legacy_array() ); + $this->assertSame( [ 'isNewsSeoActive' => $is_woo_seo_active ], $this->instance->to_array() ); + } + + /** + * Data provider for test_is_enabled. + * + * @return array> + */ + public static function data_provider_is_enabled() { + return [ + 'Enabled' => [ + 'news_seo_enabled' => true, + 'expected' => true, + ], + 'Disabled' => [ + 'news_seo_enabled' => false, + 'expected' => false, + ], + ]; + } +}