Skip to content

Commit

Permalink
updated tests with error names
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Jan 8, 2025
1 parent 0c229c1 commit 75533a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/Checker/Checks/Plugin_Repo/File_Type_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function ( $file ) use ( $plugin_path ) {
$this->add_result_error_for_file(
$result,
__( 'Case-Sensitive duplicated folders were found. They\'ll be problematic in different systems.', 'plugin-check' ),
'duplicated_folders',
'case_sensitive_folders',
implode( ', ', $case_sensitive_folders ),
0,
0,
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/Checker/Checks/File_Type_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function test_run_with_badly_named_errors() {
$this->assertCount( 1, wp_list_filter( $errors['badly|file%name!@#$%^&*()+=[]{};:"\'<>,?|`~.php'][0][0], array( 'code' => 'badly_named_files' ) ) );
}

public function test_run_with_duplicated_named_errors() {
public function test_run_with_case_sensitive_named_errors() {
// Initialize the Check_Context with a plugin path that mimics the directory structure.
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-file-type-badly-named-files-errors/load.php' );

Expand All @@ -155,7 +155,7 @@ public function test_run_with_duplicated_named_errors() {

$errors = $check_result->get_errors();

$this->assertCount( 1, wp_list_filter( $errors['custom-file.php'][0][0], array( 'code' => 'duplicated_files' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['custom-file.php'][0][0], array( 'code' => 'case_sensitive_files' ) ) );

// Define the custom file list with duplicate folder names as they would appear in a plugin directory.
$custom_files = array(
Expand All @@ -167,7 +167,7 @@ public function test_run_with_duplicated_named_errors() {
$result = $check_files_method->invoke( $check, $check_result, $custom_files );
$errors = $check_result->get_errors();

$this->assertCount( 1, wp_list_filter( $errors['sub directory/'][0][0], array( 'code' => 'duplicated_folders' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['sub directory/'][0][0], array( 'code' => 'case_sensitive_folders' ) ) );
}

public function test_run_with_library_core_errors() {
Expand Down

0 comments on commit 75533a5

Please sign in to comment.