Skip to content

Commit

Permalink
Test realpath
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Sep 9, 2024
1 parent 9d72214 commit f30c1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/Plugin_Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public function main_file() {
*/
public function path( $relative_path = '/' ) {
if ( is_dir( $this->main_file ) ) {
return trailingslashit( $this->main_file ) . ltrim( $relative_path, '/' );
return realpath( trailingslashit( $this->main_file ) . ltrim( $relative_path, '/' ) ) . '/';

Check warning on line 104 in includes/Plugin_Context.php

View check run for this annotation

Codecov / codecov/patch

includes/Plugin_Context.php#L104

Added line #L104 was not covered by tests
} else {
return plugin_dir_path( $this->main_file ) . ltrim( $relative_path, '/' );
return realpath( plugin_dir_path( $this->main_file ) . ltrim( $relative_path, '/' ) ) . '/';
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/behat/features/plugin-check-remote.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Feature: Test that the WP-CLI plugin check command works with remote ZIP url.
Scenario: Test with valid ZIP
When I run the WP-CLI command `plugin check https://github.com/WordPress/plugin-check/raw/trunk/tests/behat/testdata/foo-bar-wp.zip --fields=code,type --format=csv`
Then STDOUT should contain:
"""
FILE: foo-bar-wp.php
"""
And STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR
"""
Expand Down

0 comments on commit f30c1b9

Please sign in to comment.