1{
2 lib,
3 php,
4 ...
5}:
6{
7 name = "php-${php.version}-httpd-test";
8 meta.maintainers = lib.teams.php.members;
9
10 nodes.machine =
11 {
12 config,
13 pkgs,
14 ...
15 }:
16 {
17 services.httpd = {
18 enable = true;
19 adminAddr = "admin@phpfpm";
20 virtualHosts."phpfpm" =
21 let
22 testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
23 in
24 {
25 documentRoot = "${testdir}/web";
26 locations."/" = {
27 index = "index.php index.html";
28 };
29 };
30 phpPackage = php;
31 enablePHP = true;
32 };
33 };
34 testScript =
35 { ... }:
36 ''
37 machine.wait_for_unit("httpd.service")
38
39 # Check so we get an evaluated PHP back
40 response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
41 assert "PHP Version ${php.version}" in response, "PHP version not detected"
42
43 # Check so we have database and some other extensions loaded
44 for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
45 assert ext in response, f"Missing {ext} extension"
46 '';
47}