2020-05-15 21:57:56 +00:00
|
|
|
import ../make-test-python.nix ({pkgs, ...}:
|
2021-06-06 07:54:09 +00:00
|
|
|
let
|
|
|
|
testdir = pkgs.writeTextDir "www/info.php" "<?php phpinfo();";
|
2020-05-15 21:57:56 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
name = "unit-php-test";
|
2021-01-15 22:18:51 +00:00
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
|
2020-05-15 21:57:56 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
nodes.machine = { config, lib, pkgs, ... }: {
|
2020-05-15 21:57:56 +00:00
|
|
|
services.unit = {
|
|
|
|
enable = true;
|
2021-06-06 07:54:09 +00:00
|
|
|
config = pkgs.lib.strings.toJSON {
|
2022-07-18 16:21:45 +00:00
|
|
|
listeners."*:9081".application = "php_81";
|
|
|
|
applications.php_81 = {
|
|
|
|
type = "php 8.1";
|
2021-06-06 07:54:09 +00:00
|
|
|
processes = 1;
|
|
|
|
user = "testuser";
|
|
|
|
group = "testgroup";
|
|
|
|
root = "${testdir}/www";
|
|
|
|
index = "info.php";
|
2022-07-18 16:21:45 +00:00
|
|
|
options.file = "${pkgs.unit.usedPhp81}/lib/php.ini";
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
};
|
2020-05-15 21:57:56 +00:00
|
|
|
};
|
|
|
|
users = {
|
|
|
|
users.testuser = {
|
2021-05-20 23:08:51 +00:00
|
|
|
isSystemUser = true;
|
2021-06-06 07:54:09 +00:00
|
|
|
uid = 1080;
|
2020-05-15 21:57:56 +00:00
|
|
|
group = "testgroup";
|
|
|
|
};
|
|
|
|
groups.testgroup = {
|
2021-06-06 07:54:09 +00:00
|
|
|
gid = 1080;
|
2020-05-15 21:57:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
testScript = ''
|
2022-07-18 16:21:45 +00:00
|
|
|
machine.start()
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
machine.wait_for_unit("unit.service")
|
2022-07-18 16:21:45 +00:00
|
|
|
machine.wait_for_open_port(9081)
|
2020-06-02 18:00:15 +00:00
|
|
|
|
|
|
|
# Check so we get an evaluated PHP back
|
2022-07-18 16:21:45 +00:00
|
|
|
response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9081/")
|
|
|
|
assert "PHP Version ${pkgs.unit.usedPhp81.version}" in response, "PHP version not detected"
|
2020-06-02 18:00:15 +00: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"
|
2022-07-18 16:21:45 +00:00
|
|
|
|
|
|
|
machine.shutdown()
|
2020-05-15 21:57:56 +00:00
|
|
|
'';
|
|
|
|
})
|