old tests moved away to make place for new PHPUnit tests (see www.phpunit.de)
[shipsimu.git] / tests / personell-test.php
1 <?php
2 define('TEST', true);
3 // Change directory
4 @chdir("..");
5
6 // Load config file
7 require(dirname(dirname(__FILE__)) . "/inc/config.php");
8
9 // Load all include files
10 require(PATH . "inc/includes.php");
11
12 // Load all game classes
13 require(PATH . "inc/classes.php");
14
15 // Set default application
16 FrameworkConfiguration::getInstance()->setConfigEntry("default_application", "ship-simu");
17
18 // Set testing mode (no starter.php will be loaded!)
19 define('TEST_MODE', true);
20
21 // Load the "selector"
22 require(PATH . "inc/selector.php");
23
24 // Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen
25 // jetzt die Personalliste wiederherstellen
26 try {
27         $personell = SimulatorPersonell::createSimulatorPersonellByID("SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98");
28 } catch (InvalidIDFormatException $e) {
29         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
30                 $e->getMessage()
31         ));
32 } catch (InvalidArrayCountException $e) {
33         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
34                 $e->getMessage()
35         ));
36 } catch (NullPointerException $e) {
37         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
38                 $e->getMessage()
39         ));
40 } catch (NoObjectException $e) {
41         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
42                 $e->getMessage()
43         ));
44 } catch (MissingMethodException $e) {
45         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
46                 $e->getMessage()
47         ));
48 } catch (FileIsEmptyException $e) {
49         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
50                 $e->getMessage()
51         ));
52 } catch (FilePointerNotOpenedException $e) {
53         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
54                 $e->getMessage()
55         ));
56 } catch (InvalidArrayCountException $e) {
57         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
58                 $e->getMessage()
59         ));
60 } catch (InvalidMD5ChecksumException $e) {
61         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
62                 $e->getMessage()
63         ));
64 } catch (InvalidDataLengthException $e) {
65         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
66                 $e->getMessage()
67         ));
68 } catch (InvalidSimulatorIDException $e) {
69         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
70                 $e->getMessage()
71         ));
72 } catch (MismatchingCompressorsException $e) {
73         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
74                 $e->getMessage()
75         ));
76 } catch (ContainerItemIsNullException $e) {
77         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
78                 $e->getMessage()
79         ));
80 } catch (ContainerItemIsNoArrayException $e) {
81         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
82                 $e->getMessage()
83         ));
84 } catch (ContainerMaybeDamagedException $e) {
85         die(sprintf("[Main:] Die Personenliste konnte nicht erstellt werden. Grund: <strong>%s</strong><br />\n",
86                 $e->getMessage()
87         ));
88 }
89
90 // Personal-Objekt debuggen
91 if (defined('DEBUG_PERSONELL_OBJ')) {
92         echo sprintf("Das Personal-Objekt sieht wie folgt aus:<br />
93 <pre>%s</pre>\n",
94                 print_r($personell, true)
95         );
96 }
97
98 // Erstmal bis hier hin
99 exit();
100
101 // Etwas zum Testen...
102 try {
103         $personell = SimulatorPersonell::createSimulatorPersonell(20);
104 } catch (NullPointerException $e) {
105         die(sprintf("[Main:] Personenliste nicht angelegt. Grund: <strong>%s</strong><br />\n",
106                 $e->getMessage()
107         ));
108 } catch (NoObjectException $e) {
109         die(sprintf("[Main:] Personenliste nicht angelegt. Grund: <strong>%s</strong><br />\n",
110                 $e->getMessage()
111         ));
112 } catch (MissingMethodException $e) {
113         die(sprintf("[Main:] Personenliste nicht angelegt. Grund: <strong>%s</strong><br />\n",
114                 $e->getMessage()
115         ));
116 }
117
118 // Personal-Objekt debuggen
119 if (defined('DEBUG_PERSONELL_OBJ')) {
120         echo sprintf("Das Personal-Objekt sieht wie folgt aus:<br />
121 <pre>%s</pre>\n",
122                 print_r($personell, true)
123         );
124 }
125
126 // Try to save the object (for testing purposes)
127 try {
128         $personell->saveObjectToDatabase();
129 } catch (NullPointerException $e) {
130         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
131                 $e->getMessage()
132         ));
133 } catch (NoObjectException $e) {
134         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
135                 $e->getMessage()
136         ));
137 } catch (InvalidObjectException $e) {
138         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
139                 $e->getMessage()
140         ));
141 } catch (MissingMethodException $e) {
142         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
143                 $e->getMessage()
144         ));
145 } catch (UnsupportedLimitationPartException $e) {
146         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
147                 $e->getMessage()
148         ));
149 } catch (GetterNotFoundException $e) {
150         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
151                 $e->getMessage()
152         ));
153 } catch (NoArrayCreatedException $e) {
154         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
155                 $e->getMessage()
156         ));
157 } catch (InvalidArrayCountException $e) {
158         die(sprintf("[Main:] Objekt nicht gespeichert. Grund: <strong>%s</strong><br />\n",
159                 $e->getMessage()
160         ));
161 }
162
163 //
164 ?>