Skip to content

Commit

Permalink
Update unit tests for modified readme check
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Jan 13, 2025
1 parent 1386290 commit ada4994
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function test_run_with_errors_multiple_parser_warnings() {
public function test_run_with_errors_parser_warnings_with_custom_set_transient_version() {
$version = '5.0';

set_transient( 'wp_plugin_check_latest_wp_version', $version );
set_transient( 'wp_plugin_check_latest_version_info', array( 'current' => '5.0.1' ) );

$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-parser-warnings/load.php' );
Expand All @@ -349,7 +349,7 @@ public function test_run_with_errors_parser_warnings_with_custom_set_transient_v

$warnings = $check_result->get_warnings();

delete_transient( 'wp_plugin_check_latest_wp_version' );
delete_transient( 'wp_plugin_check_latest_version_info' );

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.txt', $warnings );
Expand Down Expand Up @@ -473,9 +473,8 @@ public function test_run_with_errors_upgrade_notice() {
}

public function test_run_with_errors_tested_up_to_latest_plus_two_version() {
$version = '5.9'; // Target plugin has "6.1" is readme.

set_transient( 'wp_plugin_check_latest_wp_version', $version );
// Target plugin has "6.1" is readme.
set_transient( 'wp_plugin_check_latest_version_info', array( 'current' => '5.9.1' ) );

$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-md-with-errors/load.php' );
Expand All @@ -485,7 +484,7 @@ public function test_run_with_errors_tested_up_to_latest_plus_two_version() {

$errors = $check_result->get_errors();

delete_transient( 'wp_plugin_check_latest_wp_version' );
delete_transient( 'wp_plugin_check_latest_version_info' );

$this->assertNotEmpty( $errors );

Expand All @@ -497,9 +496,8 @@ public function test_run_with_errors_tested_up_to_latest_plus_two_version() {
}

public function test_run_without_errors_tested_up_to_latest_plus_one_version() {
$version = '6.0'; // Target plugin has "6.1" is readme.

set_transient( 'wp_plugin_check_latest_wp_version', $version );
// Target plugin has "6.1" is readme.
set_transient( 'wp_plugin_check_latest_version_info', array( 'current' => '6.0.1' ) );

$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-md-with-errors/load.php' );
Expand All @@ -509,15 +507,14 @@ public function test_run_without_errors_tested_up_to_latest_plus_one_version() {

$errors = $check_result->get_errors();

delete_transient( 'wp_plugin_check_latest_wp_version' );
delete_transient( 'wp_plugin_check_latest_version_info' );

$this->assertCount( 0, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'nonexistent_tested_upto_header' ) ) );
}

public function test_run_without_errors_tested_up_to_latest_stable_version() {
$version = '6.1'; // Target plugin has "6.1" is readme.

set_transient( 'wp_plugin_check_latest_wp_version', $version );
// Target plugin has "6.1" is readme.
set_transient( 'wp_plugin_check_latest_version_info', array( 'current' => '6.1.1' ) );

$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-md-with-errors/load.php' );
Expand All @@ -527,7 +524,7 @@ public function test_run_without_errors_tested_up_to_latest_stable_version() {

$errors = $check_result->get_errors();

delete_transient( 'wp_plugin_check_latest_wp_version' );
delete_transient( 'wp_plugin_check_latest_version_info' );

$this->assertCount( 0, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'nonexistent_tested_upto_header' ) ) );
}
Expand Down

0 comments on commit ada4994

Please sign in to comment.