@@ -220,7 +220,11 @@ public function test_run_with_errors_tested_upto() {
220220 $ this ->assertCount ( 1 , wp_list_filter ( $ errors ['readme.txt ' ][0 ][0 ], array ( 'code ' => 'outdated_tested_upto_header ' ) ) );
221221 }
222222
223- public function test_run_with_errors_tested_upto_minor () {
223+ public function test_run_with_errors_tested_upto_minor_same_major_version () {
224+ // Target plugin has "6.1.1" is readme.
225+ // Current version is set to 6.1.2.
226+ set_transient ( 'wp_plugin_check_latest_version_info ' , array ( 'current ' => '6.1.2 ' ) );
227+
224228 $ readme_check = new Plugin_Readme_Check ();
225229 $ check_context = new Check_Context ( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-tested-upto-minor/load.php ' );
226230 $ check_result = new Check_Result ( $ check_context );
@@ -229,15 +233,44 @@ public function test_run_with_errors_tested_upto_minor() {
229233
230234 $ errors = $ check_result ->get_errors ();
231235
236+ delete_transient ( 'wp_plugin_check_latest_version_info ' );
237+
232238 $ this ->assertNotEmpty ( $ errors );
233239 $ this ->assertArrayHasKey ( 'readme.txt ' , $ errors );
234240
235- // Check for tested upto.
241+ // Check for tested upto minor error .
236242 $ this ->assertArrayHasKey ( 0 , $ errors ['readme.txt ' ] );
237243 $ this ->assertArrayHasKey ( 0 , $ errors ['readme.txt ' ][0 ] );
238244 $ this ->assertCount ( 1 , wp_list_filter ( $ errors ['readme.txt ' ][0 ][0 ], array ( 'code ' => 'invalid_tested_upto_minor ' ) ) );
239245 }
240246
247+ public function test_run_with_errors_tested_upto_minor_different_major_version () {
248+ // Target plugin has "6.1.1" is readme.
249+ // Current version is set to 6.2.1.
250+ set_transient ( 'wp_plugin_check_latest_version_info ' , array ( 'current ' => '6.2.1 ' ) );
251+
252+ $ readme_check = new Plugin_Readme_Check ();
253+ $ check_context = new Check_Context ( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-tested-upto-minor/load.php ' );
254+ $ check_result = new Check_Result ( $ check_context );
255+
256+ $ readme_check ->run ( $ check_result );
257+
258+ $ errors = $ check_result ->get_errors ();
259+
260+ delete_transient ( 'wp_plugin_check_latest_version_info ' );
261+
262+ $ this ->assertNotEmpty ( $ errors );
263+ $ this ->assertArrayHasKey ( 'readme.txt ' , $ errors );
264+
265+ // Check for tested upto minor error.
266+ $ this ->assertArrayHasKey ( 0 , $ errors ['readme.txt ' ] );
267+ $ this ->assertArrayHasKey ( 0 , $ errors ['readme.txt ' ][0 ] );
268+ $ this ->assertCount ( 0 , wp_list_filter ( $ errors ['readme.txt ' ][0 ][0 ], array ( 'code ' => 'invalid_tested_upto_minor ' ) ) );
269+
270+ // There must be outdated_tested_upto_header error.
271+ $ this ->assertCount ( 1 , wp_list_filter ( $ errors ['readme.txt ' ][0 ][0 ], array ( 'code ' => 'outdated_tested_upto_header ' ) ) );
272+ }
273+
241274 public function test_run_with_errors_missing_readme_headers () {
242275 $ readme_check = new Plugin_Readme_Check ();
243276 $ check_context = new Check_Context ( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-upgrade-notice/load.php ' );
0 commit comments