Skip to content

Commit

Permalink
Add unit test for updated message
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Dec 11, 2024
1 parent 990d3eb commit 83277ea
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ public function test_run_with_errors() {
}
}

public function test_run_with_invalid_requires_wp_header() {
set_transient( 'wp_plugin_check_latest_version_info', array( 'current' => '6.5.1' ) );

$check = new Plugin_Header_Fields_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-header-fields-with-errors/load.php' );
$check_result = new Check_Result( $check_context );

$check->run( $check_result );

$errors = $check_result->get_errors();

$this->assertNotEmpty( $errors );

$error_items = wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_wp' ) );

$this->assertCount( 1, $error_items );
$this->assertStringContainsString( 'such as "6.5" or "6.4"', reset( $error_items )['message'] );

delete_transient( 'wp_plugin_check_latest_version_info' );
}

public function test_run_with_valid_requires_plugins_header() {
/*
* Test plugin has following valid header.
Expand Down

0 comments on commit 83277ea

Please sign in to comment.