xref: /unit/test/unit/applications/lang/php.py (revision 1673:883f2f79c2f6)
1from conftest import option
2import os
3import shutil
4
5from unit.applications.proto import TestApplicationProto
6
7
8class TestApplicationPHP(TestApplicationProto):
9    application_type = "php"
10
11    def load(self, script, index='index.php', **kwargs):
12        script_path = option.test_dir + '/php/' + script
13
14        if kwargs.get('isolation') and kwargs['isolation'].get('rootfs'):
15            rootfs = kwargs['isolation']['rootfs']
16
17            if not os.path.exists(rootfs + '/app/php/'):
18                os.makedirs(rootfs + '/app/php/')
19
20            if not os.path.exists(rootfs + '/app/php/' + script):
21                shutil.copytree(script_path, rootfs + '/app/php/' + script)
22
23            script_path = '/app/php/' + script
24
25        self._load_conf(
26            {
27                "listeners": {"*:7080": {"pass": "applications/" + script}},
28                "applications": {
29                    script: {
30                        "type": self.get_application_type(),
31                        "processes": {"spare": 0},
32                        "root": script_path,
33                        "working_directory": script_path,
34                        "index": index,
35                    }
36                },
37            },
38            **kwargs
39        )
40