Skip to content

Commit 8cc7b58

Browse files
committed
Add test cases for mobile alternate link wp_head hook
1 parent 1ba5bbb commit 8cc7b58

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/php/src/MobileRedirectionTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@ public function test_maybe_add_mobile_switcher_hooks() {
168168
$this->assertSame( 10, has_action( 'amp_post_template_footer', [ $this->instance, 'add_mobile_version_switcher_link' ] ) );
169169
}
170170

171+
/**
172+
* @covers ::add_mobile_alternative_link_head_hook()
173+
*/
174+
public function test_add_mobile_alternative_link_head_hook() {
175+
AMP_Options_Manager::update_option( Option::THEME_SUPPORT, AMP_Theme_Support::STANDARD_MODE_SLUG );
176+
$this->go_to( '/' );
177+
$this->instance->add_mobile_alternative_link_head_hook();
178+
$this->assertTrue( amp_is_request() );
179+
$this->assertFalse( has_action( 'wp_head', [ $this->instance, 'add_mobile_alternative_link' ] ) );
180+
181+
AMP_Options_Manager::update_option( Option::THEME_SUPPORT, AMP_Theme_Support::TRANSITIONAL_MODE_SLUG );
182+
$this->go_to( '/' );
183+
$this->instance->add_mobile_alternative_link_head_hook();
184+
$this->assertFalse( amp_is_request() );
185+
$this->assertSame( 10, has_action( 'wp_head', [ $this->instance, 'add_mobile_alternative_link' ] ) );
186+
}
187+
171188
/**
172189
* Get data for test_mobile_alternate_link_hook
173190
*

0 commit comments

Comments
 (0)