diff --git a/src/Path/Finder/WpCliPathFinder.php b/src/Path/Finder/WpCliPathFinder.php index 2c370b6..319768b 100644 --- a/src/Path/Finder/WpCliPathFinder.php +++ b/src/Path/Finder/WpCliPathFinder.php @@ -35,10 +35,15 @@ public function find(): string throw new Exception(); } - if (!$firstMatch->isExecutable()) { + if (!$this->isWindows() && !$firstMatch->isExecutable()) { throw new Exception('The matched WP-CLI binary is not executable.'); } return $firstMatch->getPathname(); } + + private function isWindows(): bool + { + return \DIRECTORY_SEPARATOR === '\\'; + } } diff --git a/tests/phpunit/Functional/Path/Finder/WpCliPathFinderTest.php b/tests/phpunit/Functional/Path/Finder/WpCliPathFinderTest.php index 715b58d..6ae89b8 100644 --- a/tests/phpunit/Functional/Path/Finder/WpCliPathFinderTest.php +++ b/tests/phpunit/Functional/Path/Finder/WpCliPathFinderTest.php @@ -51,9 +51,14 @@ public function testWpContentDirectoryIsIgnoredWhenWpCliIsLocated(): void public function testThrowsWhenLocatedWpCliIsNotExecutable(): void { + if (\DIRECTORY_SEPARATOR === '\\') { + $this->markTestSkipped('Windows has no POSIX file permissions to test.'); + } + $this->expectExceptionMessageMatches('/The matched WP-CLI binary is not executable/'); $this->filesystem->appendToFile($this->workspace . '/acme/vendor/bin/wp', ''); + $this->filesystem->chmod($this->workspace . '/acme/vendor/bin/wp', 0644); (new WpCliPathFinder( $this->localDependencyPath($this->workspace . '/acme'),