Skip to content

Commit

Permalink
Add tests for no stable tag in readme check
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Jan 25, 2024
1 parent 2b29dbc commit 4fba8a4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Plugin Name: Test Plugin Readme Errors (no stable tag)
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Readme check.
* Requires at least: 6.0
* Requires PHP: 5.6
* Version: n.e.x.t
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: test-plugin-check-errors
*
* @package test-plugin-check-errors
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=== Test Plugin with readme ===

Contributors: plugin-check
Requires at least: 6.0
Tested up to: 6.1
Requires PHP: 5.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: testing, security

Plugin description.
24 changes: 24 additions & 0 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ public function test_run_with_errors_stable_tag() {
$this->assertEquals( 'stable_tag_mismatch', $errors['readme.txt'][0][0][1]['code'] );
}

public function test_run_with_errors_no_stable_tag() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-no-stable-tag/load.php' );
$check_result = new Check_Result( $check_context );

$readme_check->run( $check_result );

$errors = $check_result->get_errors();
$warnings = $check_result->get_warnings();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.txt', $errors );
$this->assertEquals( 1, $check_result->get_error_count() );

$this->assertEmpty( $warnings );
$this->assertEquals( 0, $check_result->get_warning_count() );

// Check for no stable tag error.
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.txt'][0][0][0] );
$this->assertEquals( 'no_stable_tag', $errors['readme.txt'][0][0][0]['code'] );
}

public function test_run_with_errors_license() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-license/load.php' );
Expand Down

0 comments on commit 4fba8a4

Please sign in to comment.