Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions examples/http-client/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,28 @@ pub static TESTS_PHP_DIR: LazyLock<PathBuf> = 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"));
}
14 changes: 14 additions & 0 deletions examples/http-client/tests/php/router.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// Copyright (c) 2022 PHPER Framework Team
// PHPER is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

header('Content-Type: text/plain');
echo "Hello phper!";
4 changes: 2 additions & 2 deletions examples/http-client/tests/php/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
->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(),
Expand All @@ -35,4 +35,4 @@
$client->get("file:///")->send();
throw new AssertionError("no throw exception");
} catch (HttpClientException $e) {
}
}
Loading