Skip to content

Commit

Permalink
refactor: implement options helper
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
vraja-pro committed Sep 16, 2024
1 parent 66c590e commit 0a7eb2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/editors/framework/site/base-site-information.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function get_site_information(): array {
'isRtl' => \is_rtl(),
'isPremium' => $this->product_helper->is_premium(),
'siteIconUrl' => \get_site_icon_url(),
'sitewideSocialImage' => WPSEO_Options::get( 'og_default_image' ),
'sitewideSocialImage' => $this->options_helper->get( 'og_default_image' ),
// phpcs:ignore Generic.ControlStructures.DisallowYodaConditions -- Bug: squizlabs/PHP_CodeSniffer#2962.
'isPrivateBlog' => ( (string) \get_option( 'blog_public' ) ) === '0',
];
Expand All @@ -109,7 +109,7 @@ public function get_legacy_site_information(): array {
'linkParams' => $this->short_link_helper->get_query_params(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'wistiaEmbedPermission' => $this->wistia_embed_permission_repository->get_value_for_user( \get_current_user_id() ),
'sitewideSocialImage' => WPSEO_Options::get( 'og_default_image' ),
'sitewideSocialImage' => $this->options_helper->get( 'og_default_image' ),
// phpcs:ignore Generic.ControlStructures.DisallowYodaConditions -- Bug: squizlabs/PHP_CodeSniffer#2962.
'isPrivateBlog' => ( (string) \get_option( 'blog_public' ) ) === '0',
'metabox' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function test_legacy_site_information() {
$this->promotion_manager->expects( 'get_current_promotions' )->andReturn( [ 'the promotion', 'another one' ] );
$this->promotion_manager->expects( 'is' )->andReturnFalse();
$this->short_link_helper->expects( 'get' )->andReturn( 'https://expl.c' );
$this->options_helper->expects( 'get' )->with( 'og_default_image' )->andReturn( null );

$this->assertSame( $expected, $this->instance->get_legacy_site_information() );
}
Expand Down Expand Up @@ -217,6 +218,7 @@ public function test_site_information() {
$this->promotion_manager->expects( 'get_current_promotions' )->andReturn( [ 'the promotion', 'another one' ] );
$this->promotion_manager->expects( 'is' )->andReturnFalse();
$this->short_link_helper->expects( 'get' )->andReturn( 'https://expl.c' );
$this->options_helper->expects( 'get' )->with( 'og_default_image' )->andReturn( null );

$this->assertSame( $expected, $this->instance->get_site_information() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected function set_up() {

$this->instance->set_term( $mock_term );
$this->options_helper->expects( 'get' )->with( 'stripcategorybase', false )->andReturnFalse();
$this->options_helper->expects( 'get' )->with( 'og_default_image' )->andReturn( null );

$this->set_mocks();
}
Expand Down
11 changes: 10 additions & 1 deletion tests/WP/Editors/Framework/Site/Post_Site_Information_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Mockery;
use Yoast\WP\SEO\Actions\Alert_Dismissal_Action;
use Yoast\WP\SEO\Editors\Framework\Site\Post_Site_Information;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
use Yoast\WP\SEO\Introductions\Infrastructure\Wistia_Embed_Permission_Repository;
Expand Down Expand Up @@ -64,6 +65,13 @@ final class Post_Site_Information_Test extends TestCase {
*/
private $product_helper;

/**
* The options helper.
*
* @var Mockery\MockInterface|Options_Helper $options_helper
*/
private $options_helper;

/**
* The Post_Site_Information container.
*
Expand All @@ -84,9 +92,10 @@ public function set_up() {
$this->wistia_embed_repo->expects( 'get_value_for_user' )->with( 0 )->andReturnTrue();
$this->meta_surface = \YoastSEO()->meta;
$this->product_helper = \YoastSEO()->helpers->product;
$this->options_helper = \YoastSEO()->helpers->options;
$this->alert_dismissal_action = \YoastSEO()->classes->get( Alert_Dismissal_Action::class );

$this->instance = new Post_Site_Information( $this->promotion_manager, $this->short_link_helper, $this->wistia_embed_repo, $this->meta_surface, $this->product_helper, $this->alert_dismissal_action );
$this->instance = new Post_Site_Information( $this->promotion_manager, $this->short_link_helper, $this->wistia_embed_repo, $this->meta_surface, $this->product_helper, $this->alert_dismissal_action, $this->options_helper );
$this->instance->set_permalink( 'perma' );
}

Expand Down

0 comments on commit 0a7eb2d

Please sign in to comment.