Skip to content

Commit 0d4e66f

Browse files
committed
added test for duplicated protocol
1 parent ba91cf3 commit 0d4e66f

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Plugin Name: Test Header fields with errors
4+
* Plugin URI: https://example.com/sample-link
5+
* Description: Here is a short description of the plugin.
6+
* Requires at least: Recent version
7+
* Requires PHP: Latest version
8+
* Author: WordPress Performance Team
9+
* Author URI: https://http://example.com/
10+
* Text Domain: test-mismathed-textdomain-here
11+
* Domain Path: /nonexistent-folder
12+
* Network: random-value
13+
* GitHub Plugin URI: johndoe/package
14+
* Requires Plugins: Example Plugin, OtherPlugin
15+
*
16+
* @package test-plugin-header-fields-with-errors
17+
*/

tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,20 @@ public function test_run_without_errors_requires_at_least_latest_version() {
167167

168168
$this->assertEmpty( $errors );
169169
}
170+
171+
public function test_run_with_errors_duplicated_protocol_is_valid_url() {
172+
$check = new Plugin_Header_Fields_Check();
173+
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-header-fields-duplicated-protocol-with-errors/load.php' );
174+
$check_result = new Check_Result( $check_context );
175+
176+
$check->run( $check_result );
177+
178+
$errors = $check_result->get_errors();
179+
180+
$filtered_items = wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_author_uri' ) );
181+
182+
$this->assertCount( 1, $filtered_items );
183+
$this->assertStringContainsString( 'Author URI', $filtered_items[1]['message'] );
184+
$this->assertStringContainsString( 'is not valid', $filtered_items[1]['message'] );
185+
}
170186
}

0 commit comments

Comments
 (0)