1#
2# Copyright (c) ZeroC, Inc. All rights reserved.
3#
4
5class IniClient(Client):
6
7    def __init__(self, iceOptions, iceProfile=None, *args, **kargs):
8        Client.__init__(self, *args, **kargs)
9        self.iceOptions = iceOptions
10        self.iceProfile = iceProfile
11
12    def setup(self, current):
13        if self.iceProfile:
14            current.createFile("ice.profiles", [
15                "[%s]" % self.iceProfile,
16                "ice.config=\"config.client\"",
17                "ice.options=\"%s\"" % self.iceOptions,
18            ])
19        current.write("testing... ")
20
21    def teardown(self, current, success):
22        if success:
23            current.writeln("ok")
24
25    def getPhpArgs(self, current):
26        if self.iceProfile:
27            return ["-d", "ice.profiles=\"ice.profiles\""]
28        else:
29            return ["-d", "ice.options=\"{0}\"".format(self.iceOptions), "-d", "ice.config=\"config.client\""]
30
31TestSuite(__name__, [
32    ClientTestCase("php INI settings",
33                   client=IniClient("--Ice.Trace.Network=1 --Ice.Warn.Connections=1")),
34    ClientTestCase("php INI settings with profiles",
35                   client=IniClient("--Ice.Trace.Network=1 --Ice.Warn.Connections=1",
36                                    "Test",
37                                    exe="ClientWithProfile"))
38])
39