File tree Expand file tree Collapse file tree 4 files changed +42
-9
lines changed
examples/http-client/tests Expand file tree Collapse file tree 4 files changed +42
-9
lines changed Original file line number Diff line number Diff line change @@ -78,17 +78,13 @@ jobs:
78
78
sudo rm -f /usr/sbin/php-fpm
79
79
sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm
80
80
81
- - name : Setup php-fpm for Macos
82
- if : matrix.os == 'macos-14'
83
- run : |
84
- brew install php@${{ matrix.php-version }}
85
- echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/bin" >> "$GITHUB_PATH"
86
- echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/sbin" >> "$GITHUB_PATH"
87
-
88
81
- name : PHP version
89
82
run : |
83
+ which php
90
84
php --version
85
+ which php-fpm
91
86
php-fpm --version
87
+ which php-config
92
88
php-config || true
93
89
94
90
[[ `php --version` == PHP\ ${{ matrix.php-version }}.* ]] || exit 1;
Original file line number Diff line number Diff line change @@ -32,5 +32,28 @@ pub static TESTS_PHP_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
32
32
33
33
#[ test]
34
34
fn test_php ( ) {
35
+ use std:: { process:: Command , thread:: sleep, time:: Duration } ;
36
+
37
+ let router = TESTS_PHP_DIR . join ( "router.php" ) ;
38
+ let server = Command :: new ( "php" )
39
+ . arg ( "-S" )
40
+ . arg ( "127.0.0.1:8000" )
41
+ . arg ( "-t" )
42
+ . arg ( TESTS_PHP_DIR . to_str ( ) . unwrap ( ) )
43
+ . arg ( router. to_str ( ) . unwrap ( ) )
44
+ . spawn ( )
45
+ . expect ( "Failed to start PHP built-in server" ) ;
46
+
47
+ struct ServerGuard ( std:: process:: Child ) ;
48
+ impl Drop for ServerGuard {
49
+ fn drop ( & mut self ) {
50
+ let _ = self . 0 . kill ( ) ;
51
+ }
52
+ }
53
+ let _guard = ServerGuard ( server) ;
54
+
55
+ // Give the server time to start
56
+ sleep ( Duration :: from_secs ( 1 ) ) ;
57
+
35
58
test_php_script ( & * DYLIB_PATH , TESTS_PHP_DIR . join ( "test.php" ) ) ;
36
59
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // Copyright (c) 2022 PHPER Framework Team
4
+ // PHPER is licensed under Mulan PSL v2.
5
+ // You can use this software according to the terms and conditions of the Mulan
6
+ // PSL v2. You may obtain a copy of Mulan PSL v2 at:
7
+ // http://license.coscl.org.cn/MulanPSL2
8
+ // THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
9
+ // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
10
+ // NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ // See the Mulan PSL v2 for more details.
12
+
13
+ header ('Content-Type: text/plain ' );
14
+ echo "Hello phper! " ;
Original file line number Diff line number Diff line change 24
24
->cookie_store (true )
25
25
->build ();
26
26
27
- $ response = $ client ->get ("https ://example.com / " )->send ();
27
+ $ response = $ client ->get ("http ://localhost:8000 / " )->send ();
28
28
var_dump ([
29
29
"status " => $ response ->status (),
30
30
"headers " => $ response ->headers (),
35
35
$ client ->get ("file:/// " )->send ();
36
36
throw new AssertionError ("no throw exception " );
37
37
} catch (HttpClientException $ e ) {
38
- }
38
+ }
You can’t perform that action at this time.
0 commit comments