1import ../make-test-python.nix ({pkgs, ...}:
2let
3 testdir = pkgs.writeTextDir "www/info.php" "<?php phpinfo();";
4
5in {
6 name = "unit-php-test";
7 meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
8
9 machine = { config, lib, pkgs, ... }: {
10 services.unit = {
11 enable = true;
12 config = pkgs.lib.strings.toJSON {
13 listeners."*:9080".application = "php_80";
14 applications.php_80 = {
15 type = "php 8.0";
16 processes = 1;
17 user = "testuser";
18 group = "testgroup";
19 root = "${testdir}/www";
20 index = "info.php";
21 options.file = "${pkgs.unit.usedPhp80}/lib/php.ini";
22 };
23 };
24 };
25 users = {
26 users.testuser = {
27 isSystemUser = true;
28 uid = 1080;
29 group = "testgroup";
30 };
31 groups.testgroup = {
32 gid = 1080;
33 };
34 };
35 };
36 testScript = ''
37 machine.wait_for_unit("unit.service")
38
39 # Check so we get an evaluated PHP back
40 response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9080/")
41 assert "PHP Version ${pkgs.unit.usedPhp80.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})