Debian Codegraph @

test/testcontrols.php

raw symbols SCIP
1 #!/usr/bin/php
2 <?php
3
4 include('functions.php');
5
6 $socket = startrailcontrol();
7
8 // list controls
9 socket_write($socket, "cla\n");
10 $data = socket_read($socket, 128);
11 $numControls = substr_count($data, "\n") - 1;
12 if ($numControls != 0) {
13 stoprailcontrol($socket, "Number of controls at start is not 0");
14 }
15
16 // add virtual control
17 socket_write($socket, "ac \"Virt\" virt \"\"\n");
18 $data = explode("\n", socket_read($socket, 128));
19 if ($data[0] != 'Control "Virt" added') {
20 stoprailcontrol($socket, "Unable to add control: $data[0]");
21 }
22
23 // add cs2 control
24 socket_write($socket, "ac \"First CS2\" virt \"\"\n");
25 $data = explode("\n", socket_read($socket, 128));
26 if ($data[0] != 'Control "First CS2" added') {
27 stoprailcontrol($socket, "Unable to add control: $data[0]");
28 }
29
30 // add second cs2
31 socket_write($socket, "ac \"Second CS2\" virt \"\"\n");
32 $data = explode("\n", socket_read($socket, 128));
33 if ($data[0] != 'Control "Second CS2" added') {
34 stoprailcontrol($socket, "Unable to add control: $data[0]");
35 }
36
37 // list all controls
38 socket_write($socket, "cla\n");
39 $data = explode("\n", socket_read($socket, 128));
40 $numControls = substr_count($data, "\n") - 1;
41 if ($numControls != 3) {
42 stoprailcontrol($socket, "Number of controls at start is not 0");
43 }
44
45 // delete second cs2
46 socket_write($socket, "dc 3\n");
47 $data = explode("\n", socket_read($socket, 128));
48 if ($data[0] != 'Control "Second CS2" deleted') {
49 stoprailcontrol($socket, "Unable to add control: $data[0]");
50 }
51
52 // delete first cs2
53 socket_write($socket, "dc 2\n");
54 $data = explode("\n", socket_read($socket, 128));
55 if ($data[0] != 'Control "First CS2" deleted') {
56 stoprailcontrol($socket, "Unable to add control: $data[0]");
57 }
58
59 // delete virt
60 socket_write($socket, "dc 1\n");
61 $data = explode("\n", socket_read($socket, 128));
62 if ($data[0] != 'Control "Virt" deleted') {
63 stoprailcontrol($socket, "Unable to add control: $data[0]");
64 }
65
66
67
68 stoprailcontrol($socket);
69
70 ?>