diff --git a/includes/Core/Authentication/Clients/OAuth_Client.php b/includes/Core/Authentication/Clients/OAuth_Client.php
index 5c454b17d58..8108298790d 100644
--- a/includes/Core/Authentication/Clients/OAuth_Client.php
+++ b/includes/Core/Authentication/Clients/OAuth_Client.php
@@ -632,10 +632,10 @@ public function get_proxy_setup_url( $access_code = '', $error_code = '' ) {
'nonce' => $nonce,
'name' => rawurlencode( wp_specialchars_decode( get_bloginfo( 'name' ) ) ),
'url' => rawurlencode( $home_url ),
+ 'version' => GOOGLESITEKIT_VERSION,
'rest_root' => rawurlencode( $rest_root ),
'admin_root' => rawurlencode( $admin_root ),
'scope' => rawurlencode( $scope ),
- 'version' => GOOGLESITEKIT_VERSION,
),
$url
);
@@ -644,8 +644,8 @@ public function get_proxy_setup_url( $access_code = '', $error_code = '' ) {
$query_args = array(
'site_id' => $credentials->web->client_id,
'code' => $access_code,
- 'scope' => rawurlencode( $scope ),
'version' => GOOGLESITEKIT_VERSION,
+ 'scope' => rawurlencode( $scope ),
);
if ( 'missing_verification' === $error_code ) {
$query_args['verification_nonce'] = wp_create_nonce( 'googlesitekit_verification' );
diff --git a/tests/phpunit/integration/Core/Authentication/AuthenticationTest.php b/tests/phpunit/integration/Core/Authentication/AuthenticationTest.php
index 888f9c7422d..8179bf84a9e 100644
--- a/tests/phpunit/integration/Core/Authentication/AuthenticationTest.php
+++ b/tests/phpunit/integration/Core/Authentication/AuthenticationTest.php
@@ -95,26 +95,42 @@ protected function assertSetupDataExtended() {
);
}
- public function test_register_head_verification_tags() {
+ /**
+ * @dataProvider data_register_head_verification_tags
+ */
+ public function test_register_head_verification_tags( $saved_tag, $expected_output ) {
remove_all_actions( 'wp_head' );
remove_all_actions( 'login_head' );
$auth = new Authentication( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) );
$auth->register();
- $tag_html = '';
- set_transient( 'googlesitekit_verification_meta_tags', array( $tag_html ) );
+ set_transient( 'googlesitekit_verification_meta_tags', array( $saved_tag ) );
$this->assertContains(
- $tag_html,
+ $expected_output,
$this->capture_action( 'wp_head' )
);
$this->assertContains(
- $tag_html,
+ $expected_output,
$this->capture_action( 'login_head' )
);
}
+ public function data_register_head_verification_tags() {
+ return array(
+ array( // Full meta tag stored.
+ '',
+ '',
+ ),
+ array(
+ // Only verification token stored.
+ 'test-verification-content-2',
+ '',
+ ),
+ );
+ }
+
public function test_register_allowed_redirect_hosts() {
remove_all_filters( 'allowed_redirect_hosts' );
$auth = new Authentication( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) );
diff --git a/tests/phpunit/integration/Core/Authentication/Clients/OAuth_ClientTest.php b/tests/phpunit/integration/Core/Authentication/Clients/OAuth_ClientTest.php
index ec5f2b50f2d..ac422b5371b 100644
--- a/tests/phpunit/integration/Core/Authentication/Clients/OAuth_ClientTest.php
+++ b/tests/phpunit/integration/Core/Authentication/Clients/OAuth_ClientTest.php
@@ -274,6 +274,7 @@ public function test_get_proxy_setup_url() {
$url = $client->get_proxy_setup_url();
$this->assertContains( 'name=', $url );
$this->assertContains( 'url=', $url );
+ $this->assertContains( 'version=', $url );
$this->assertContains( 'rest_root=', $url );
$this->assertContains( 'admin_root=', $url );
$this->assertContains( 'scope=', $url );
@@ -285,6 +286,7 @@ public function test_get_proxy_setup_url() {
$url = $client->get_proxy_setup_url( 'temp-code' );
$this->assertContains( 'site_id=' . self::SITE_ID, $url );
$this->assertContains( 'code=temp-code', $url );
+ $this->assertContains( 'version=', $url );
$this->assertContains( 'scope=', $url );
$this->assertNotContains( 'name=', $url );
$this->assertNotContains( 'url=', $url );