@@ -1900,11 +1900,23 @@ public function test_prepare_response_for_validating_non_amp_page() {
1900
1900
/** @return array */
1901
1901
public function get_data_to_test_prepare_response_for_validating_amp_page () {
1902
1902
return [
1903
- 'no-store ' => [
1904
- false ,
1903
+ 'no-store ' => [
1904
+ 'args ' => [
1905
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_NONCE => AMP_Validation_Manager::get_amp_validate_nonce (),
1906
+ ],
1905
1907
],
1906
- 'store ' => [
1907
- true ,
1908
+ 'store ' => [
1909
+ 'args ' => [
1910
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_NONCE => AMP_Validation_Manager::get_amp_validate_nonce (),
1911
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_CACHE => true ,
1912
+ ],
1913
+ ],
1914
+ 'store_but_omit_styleshets ' => [
1915
+ 'args ' => [
1916
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_NONCE => AMP_Validation_Manager::get_amp_validate_nonce (),
1917
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_CACHE => true ,
1918
+ AMP_Validation_Manager::VALIDATE_QUERY_VAR_OMIT_STYLESHEETS => true ,
1919
+ ],
1908
1920
],
1909
1921
];
1910
1922
}
@@ -1915,34 +1927,33 @@ public function get_data_to_test_prepare_response_for_validating_amp_page() {
1915
1927
* @dataProvider get_data_to_test_prepare_response_for_validating_amp_page
1916
1928
* @covers AMP_Theme_Support::prepare_response()
1917
1929
* @covers AMP_Validation_Manager::send_validate_response()
1918
- *
1919
- * @param bool $store Whether to store results.
1920
1930
*/
1921
- public function test_prepare_response_for_validating_amp_page ( $ store ) {
1931
+ public function test_prepare_response_for_validating_amp_page ( $ args ) {
1922
1932
wp_set_current_user ( self ::factory ()->user ->create ( [ 'role ' => 'administrator ' ] ) );
1923
1933
$ this ->set_template_mode ( AMP_Theme_Support::STANDARD_MODE_SLUG );
1924
1934
$ this ->go_to ( '/ ' );
1925
1935
1926
- $ _GET [ AMP_Validation_Manager::VALIDATE_QUERY_VAR ] = [
1927
- AMP_Validation_Manager::VALIDATE_QUERY_VAR_NONCE => AMP_Validation_Manager::get_amp_validate_nonce (),
1928
- ];
1929
- if ( $ store ) {
1930
- $ _GET [ AMP_Validation_Manager::VALIDATE_QUERY_VAR ][ AMP_Validation_Manager::VALIDATE_QUERY_VAR_CACHE ] = 'true ' ;
1931
- }
1936
+ $ _GET [ AMP_Validation_Manager::VALIDATE_QUERY_VAR ] = $ args ;
1932
1937
AMP_Validation_Manager::init_validate_request ();
1933
- $ response = AMP_Theme_Support::prepare_response ( '<html amp><head></head><body><amp-layout layout="bad"></amp-layout></body></html> ' );
1938
+ AMP_Theme_Support::finish_init ();
1939
+ $ response = AMP_Theme_Support::prepare_response ( '<html amp><head><style>body{color:red}</style></head><body><amp-layout layout="bad"></amp-layout></body></html> ' );
1934
1940
$ this ->assertJson ( $ response );
1935
1941
$ data = json_decode ( $ response , true );
1936
1942
$ this ->assertArrayHasKey ( 'http_status_code ' , $ data );
1937
1943
$ this ->assertArrayHasKey ( 'php_fatal_error ' , $ data );
1938
1944
$ this ->assertArrayHasKey ( 'queried_object ' , $ data );
1939
1945
$ this ->assertArrayHasKey ( 'url ' , $ data );
1940
- $ this ->assertArrayHasKey ( 'stylesheets ' , $ data );
1946
+ if ( ! empty ( $ args [ AMP_Validation_Manager::VALIDATE_QUERY_VAR_OMIT_STYLESHEETS ] ) ) {
1947
+ $ this ->assertArrayNotHasKey ( 'stylesheets ' , $ data );
1948
+ } else {
1949
+ $ this ->assertArrayHasKey ( 'stylesheets ' , $ data );
1950
+ }
1941
1951
$ this ->assertArrayHasKey ( 'results ' , $ data );
1942
1952
$ this ->assertCount ( 1 , $ data ['results ' ] );
1943
1953
$ this ->assertEquals ( 'SPECIFIED_LAYOUT_INVALID ' , $ data ['results ' ][0 ]['error ' ]['code ' ] );
1954
+ $ this ->assertTrue ( $ data ['revalidated ' ] );
1944
1955
1945
- if ( $ store ) {
1956
+ if ( ! empty ( $ args [ AMP_Validation_Manager:: VALIDATE_QUERY_VAR_CACHE ] ) ) {
1946
1957
$ this ->assertArrayHasKey ( 'validated_url_post ' , $ data );
1947
1958
$ this ->assertArrayHasKey ( 'id ' , $ data ['validated_url_post ' ] );
1948
1959
$ this ->assertArrayHasKey ( 'edit_link ' , $ data ['validated_url_post ' ] );
0 commit comments