diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bf41238..eb3a1eb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,17 +78,13 @@ jobs: sudo rm -f /usr/sbin/php-fpm sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm - - name: Setup php-fpm for Macos - if: matrix.os == 'macos-14' - run: | - brew install php@${{ matrix.php-version }} - echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/bin" >> "$GITHUB_PATH" - echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/sbin" >> "$GITHUB_PATH" - - name: PHP version run: | + which php php --version + which php-fpm php-fpm --version + which php-config php-config || true [[ `php --version` == PHP\ ${{ matrix.php-version }}.* ]] || exit 1; diff --git a/examples/http-client/tests/integration.rs b/examples/http-client/tests/integration.rs index c3831a61..8331e5ab 100644 --- a/examples/http-client/tests/integration.rs +++ b/examples/http-client/tests/integration.rs @@ -32,5 +32,28 @@ pub static TESTS_PHP_DIR: LazyLock = LazyLock::new(|| { #[test] fn test_php() { + use std::{process::Command, thread::sleep, time::Duration}; + + let router = TESTS_PHP_DIR.join("router.php"); + let server = Command::new("php") + .arg("-S") + .arg("127.0.0.1:8000") + .arg("-t") + .arg(TESTS_PHP_DIR.to_str().unwrap()) + .arg(router.to_str().unwrap()) + .spawn() + .expect("Failed to start PHP built-in server"); + + struct ServerGuard(std::process::Child); + impl Drop for ServerGuard { + fn drop(&mut self) { + let _ = self.0.kill(); + } + } + let _guard = ServerGuard(server); + + // Give the server time to start + sleep(Duration::from_secs(1)); + test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("test.php")); } diff --git a/examples/http-client/tests/php/router.php b/examples/http-client/tests/php/router.php new file mode 100644 index 00000000..bd4c6b9e --- /dev/null +++ b/examples/http-client/tests/php/router.php @@ -0,0 +1,14 @@ +cookie_store(true) ->build(); -$response = $client->get("https://example.com/")->send(); +$response = $client->get("http://localhost:8000/")->send(); var_dump([ "status" => $response->status(), "headers" => $response->headers(), @@ -35,4 +35,4 @@ $client->get("file:///")->send(); throw new AssertionError("no throw exception"); } catch (HttpClientException $e) { -} +} \ No newline at end of file