2020-04-16 22:08:00 +02:00
|
|
|
import ../make-test-python.nix ({pkgs, ...}:
|
2021-06-03 19:17:27 +02:00
|
|
|
let
|
|
|
|
testdir = pkgs.writeTextDir "www/info.php" "<?php phpinfo();";
|
2020-04-16 22:08:00 +02:00
|
|
|
|
|
|
|
in {
|
|
|
|
name = "unit-php-test";
|
2021-01-10 20:08:30 +01:00
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
|
2020-04-16 22:08:00 +02:00
|
|
|
|
|
|
|
machine = { config, lib, pkgs, ... }: {
|
|
|
|
services.unit = {
|
|
|
|
enable = true;
|
2021-06-03 19:17:27 +02:00
|
|
|
config = pkgs.lib.strings.toJSON {
|
|
|
|
listeners."*:9080".application = "php_80";
|
|
|
|
applications.php_80 = {
|
|
|
|
type = "php 8.0";
|
|
|
|
processes = 1;
|
|
|
|
user = "testuser";
|
|
|
|
group = "testgroup";
|
|
|
|
root = "${testdir}/www";
|
|
|
|
index = "info.php";
|
|
|
|
options.file = "${pkgs.unit.usedPhp80}/lib/php.ini";
|
|
|
|
};
|
|
|
|
};
|
2020-04-16 22:08:00 +02:00
|
|
|
};
|
|
|
|
users = {
|
|
|
|
users.testuser = {
|
2021-05-09 06:41:12 +02:00
|
|
|
isSystemUser = true;
|
2021-06-03 19:17:27 +02:00
|
|
|
uid = 1080;
|
2020-04-16 22:08:00 +02:00
|
|
|
group = "testgroup";
|
|
|
|
};
|
|
|
|
groups.testgroup = {
|
2021-06-03 19:17:27 +02:00
|
|
|
gid = 1080;
|
2020-04-16 22:08:00 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
testScript = ''
|
|
|
|
machine.wait_for_unit("unit.service")
|
2020-05-30 18:52:41 +02:00
|
|
|
|
|
|
|
# Check so we get an evaluated PHP back
|
2021-06-03 19:17:27 +02:00
|
|
|
response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9080/")
|
|
|
|
assert "PHP Version ${pkgs.unit.usedPhp80.version}" in response, "PHP version not detected"
|
2020-05-30 18:52:41 +02:00
|
|
|
|
|
|
|
# Check so we have database and some other extensions loaded
|
|
|
|
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
|
|
|
|
assert ext in response, f"Missing {ext} extension"
|
2020-04-16 22:08:00 +02:00
|
|
|
'';
|
|
|
|
})
|