at master 1.5 kB view raw
1{ pkgs, ... }: 2let 3 testdir = pkgs.writeTextDir "www/info.php" "<?php phpinfo();"; 4 5in 6{ 7 name = "unit-php-test"; 8 meta.maintainers = with pkgs.lib.maintainers; [ izorkin ]; 9 10 nodes.machine = 11 { 12 config, 13 lib, 14 pkgs, 15 ... 16 }: 17 { 18 services.unit = { 19 enable = true; 20 config = pkgs.lib.strings.toJSON { 21 listeners."*:9081".application = "php_81"; 22 applications.php_81 = { 23 type = "php 8.1"; 24 processes = 1; 25 user = "testuser"; 26 group = "testgroup"; 27 root = "${testdir}/www"; 28 index = "info.php"; 29 options.file = "${pkgs.unit.usedPhp81}/lib/php.ini"; 30 }; 31 }; 32 }; 33 users = { 34 users.testuser = { 35 isSystemUser = true; 36 uid = 1080; 37 group = "testgroup"; 38 }; 39 groups.testgroup = { 40 gid = 1080; 41 }; 42 }; 43 }; 44 testScript = '' 45 machine.start() 46 47 machine.wait_for_unit("unit.service") 48 machine.wait_for_open_port(9081) 49 50 # Check so we get an evaluated PHP back 51 response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9081/") 52 assert "PHP Version ${pkgs.unit.usedPhp81.version}" in response, "PHP version not detected" 53 54 # Check so we have database and some other extensions loaded 55 for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]: 56 assert ext in response, f"Missing {ext} extension" 57 58 machine.shutdown() 59 ''; 60}