@@ -431,13 +431,45 @@ public function test_get_features() {
431431 'connected_modules ' => 'site-verification search-console pagespeed-insights ' ,
432432 'php_version ' => phpversion (),
433433 'feature_metrics ' => array (),
434+ 'amp_mode ' => '' , // No AMP mode by default.
434435 ),
435436 $ this ->request_args ['body ' ],
436437 'Get features request body should contain site credentials and platform information. '
437438 );
438439 $ this ->assertEqualSetsWithIndex ( $ expected_success_response , $ features , 'Get features should return expected feature data. ' );
439440 }
440441
442+ /**
443+ * @dataProvider amp_mode_provider
444+ */
445+ public function test_get_features_with_amp_mode ( $ amp_mode , $ context_method ) {
446+ // Remove the filter being added by Modules::register() or any other class during bootstrap.
447+ remove_all_filters ( 'googlesitekit_feature_metrics ' );
448+
449+ list ( $ credentials , $ site_id , $ site_secret ) = $ this ->get_credentials ();
450+
451+ $ context = call_user_func ( array ( $ this , $ context_method ) );
452+ $ google_proxy = new Google_Proxy ( $ context );
453+
454+ $ expected_url = $ google_proxy ->url ( Google_Proxy::FEATURES_URI );
455+ $ expected_success_response = array (
456+ 'test.featureName ' => array ( 'enabled ' => true ),
457+ );
458+
459+ $ this ->mock_http_request ( $ expected_url , $ expected_success_response );
460+ $ google_proxy ->get_features ( $ credentials , new OAuth_Client ( $ context , null , null , $ credentials , $ google_proxy ) );
461+
462+ // Ensure amp_mode is set to the expected value.
463+ $ this ->assertEquals ( $ amp_mode , $ this ->request_args ['body ' ]['amp_mode ' ], "Get features request should include ' $ amp_mode' amp_mode. " );
464+ }
465+
466+ public function amp_mode_provider () {
467+ return array (
468+ 'primary AMP mode ' => array ( 'primary ' , 'get_amp_primary_context ' ),
469+ 'secondary AMP mode ' => array ( 'secondary ' , 'get_amp_secondary_context ' ),
470+ );
471+ }
472+
441473 public function test_count_connected_users () {
442474 $ context = new Context ( GOOGLESITEKIT_PLUGIN_MAIN_FILE );
443475 $ meta_key = ( new User_Options ( $ context ) )->get_meta_key ( OAuth_Client::OPTION_ACCESS_TOKEN );
0 commit comments