@@ -105,11 +105,17 @@ |
||
105 | 105 | $activeConfig->roles = $rolesTable->$testEnvName; |
106 | 106 | } |
107 | 107 | |
108 | + /** |
|
109 | + * @param Injectables $injectables |
|
110 | + */ |
|
108 | 111 | public function mergeStoryplayerConfig($injectables, $spConf) |
109 | 112 | { |
110 | 113 | $this->mergeData('storyplayer', $spConf); |
111 | 114 | } |
112 | 115 | |
116 | + /** |
|
117 | + * @param Injectables $injectables |
|
118 | + */ |
|
113 | 119 | public function mergeSystemUnderTestConfig($injectables, SystemUnderTestConfig $sutConfig = null) |
114 | 120 | { |
115 | 121 | // do we have a system under test? |
@@ -75,43 +75,43 @@ discard block |
||
75 | 75 | */ |
76 | 76 | class ActiveConfig extends WrappedConfig |
77 | 77 | { |
78 | - public function init(Injectables $injectables) |
|
79 | - { |
|
80 | - // we start off with the built-in config |
|
81 | - $this->mergeData('storyplayer', $injectables->defaultConfig); |
|
82 | - |
|
83 | - // these are the initial variables we want |
|
84 | - $this->setData('storyplayer.ipAddress', $this->getHostIpAddress()); |
|
85 | - $this->setData('storyplayer.currentDir', getcwd()); |
|
86 | - $this->setData('storyplayer.user.home', getenv('HOME')); |
|
87 | - |
|
88 | - // we also want to link in the hosts and roles tables, to make |
|
89 | - // it a lot easier for Prose modules |
|
90 | - $activeConfig = $this->getConfig(); |
|
78 | + public function init(Injectables $injectables) |
|
79 | + { |
|
80 | + // we start off with the built-in config |
|
81 | + $this->mergeData('storyplayer', $injectables->defaultConfig); |
|
82 | + |
|
83 | + // these are the initial variables we want |
|
84 | + $this->setData('storyplayer.ipAddress', $this->getHostIpAddress()); |
|
85 | + $this->setData('storyplayer.currentDir', getcwd()); |
|
86 | + $this->setData('storyplayer.user.home', getenv('HOME')); |
|
87 | + |
|
88 | + // we also want to link in the hosts and roles tables, to make |
|
89 | + // it a lot easier for Prose modules |
|
90 | + $activeConfig = $this->getConfig(); |
|
91 | 91 | $runtimeConfig = $injectables->getRuntimeConfig(); |
92 | 92 | $runtimeConfigManager = $injectables->getRuntimeConfigManager(); |
93 | 93 | $testEnvName = $injectables->activeTestEnvironmentName; |
94 | 94 | |
95 | - $hostsTable = $runtimeConfigManager->getTable($runtimeConfig, 'hosts'); |
|
95 | + $hostsTable = $runtimeConfigManager->getTable($runtimeConfig, 'hosts'); |
|
96 | 96 | if (!isset($hostsTable->$testEnvName)) { |
97 | 97 | $hostsTable->$testEnvName = new BaseObject; |
98 | 98 | } |
99 | 99 | $activeConfig->hosts = $hostsTable->$testEnvName; |
100 | 100 | |
101 | - $rolesTable = $runtimeConfigManager->getTable($runtimeConfig, 'roles'); |
|
101 | + $rolesTable = $runtimeConfigManager->getTable($runtimeConfig, 'roles'); |
|
102 | 102 | if (!isset($rolesTable->$testEnvName)) { |
103 | 103 | $rolesTable->$testEnvName = new BaseObject; |
104 | 104 | } |
105 | 105 | $activeConfig->roles = $rolesTable->$testEnvName; |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - public function mergeStoryplayerConfig($injectables, $spConf) |
|
109 | - { |
|
110 | - $this->mergeData('storyplayer', $spConf); |
|
111 | - } |
|
108 | + public function mergeStoryplayerConfig($injectables, $spConf) |
|
109 | + { |
|
110 | + $this->mergeData('storyplayer', $spConf); |
|
111 | + } |
|
112 | 112 | |
113 | - public function mergeSystemUnderTestConfig($injectables, SystemUnderTestConfig $sutConfig = null) |
|
114 | - { |
|
113 | + public function mergeSystemUnderTestConfig($injectables, SystemUnderTestConfig $sutConfig = null) |
|
114 | + { |
|
115 | 115 | // do we have a system under test? |
116 | 116 | if (!isset($injectables->activeSystemUnderTestName) || $sutConfig === null) { |
117 | 117 | $this->setData('systemundertest', null); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | // merge in the loaded config |
125 | 125 | $this->mergeData('systemundertest', $sutConfig->getConfig()); |
126 | - } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param \DataSift\Storyplayer\TestEnvironmentsLib\TestEnvironmentsConfig|\DataSift\Storyplayer\DefinitionLib\TestEnvironment_Definition $envConfig |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - public function mergeTestEnvironmentConfig($injectables, $envConfig = null) |
|
135 | - { |
|
134 | + public function mergeTestEnvironmentConfig($injectables, $envConfig = null) |
|
135 | + { |
|
136 | 136 | // do we have a test environment? |
137 | 137 | if (!isset($injectables->activeTestEnvironmentName) || $envConfig === null) { |
138 | 138 | $this->setData('target', null); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | $this->setData('target.name', $injectables->activeTestEnvironmentName); |
144 | 144 | |
145 | 145 | // merge in the loaded config |
146 | - $this->mergeData('target', $envConfig->getConfig()); |
|
147 | - } |
|
146 | + $this->mergeData('target', $envConfig->getConfig()); |
|
147 | + } |
|
148 | 148 | |
149 | 149 | protected function getHostIpAddress() |
150 | 150 | { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | // we also want to link in the hosts and roles tables, to make |
89 | 89 | // it a lot easier for Prose modules |
90 | - $activeConfig = $this->getConfig(); |
|
90 | + $activeConfig = $this->getConfig(); |
|
91 | 91 | $runtimeConfig = $injectables->getRuntimeConfig(); |
92 | 92 | $runtimeConfigManager = $injectables->getRuntimeConfigManager(); |
93 | 93 | $testEnvName = $injectables->activeTestEnvironmentName; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | // does the adapter have an IP address? |
180 | 180 | try { |
181 | 181 | $ipAddress = $netifaces->getIpAddress($adapterToTest); |
182 | - } catch(NetifacesException $e){ |
|
182 | + } catch (NetifacesException $e) { |
|
183 | 183 | // We couldn't get an IP address |
184 | 184 | $ipAddress = null; |
185 | 185 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | // this sucks |
214 | 214 | throw new NetifacesException("Unable to determine IP address"); |
215 | 215 | |
216 | - } catch (NetifacesException $e){ |
|
216 | + } catch (NetifacesException $e) { |
|
217 | 217 | throw new Exception("could not determine IP address of host machine"); |
218 | 218 | } |
219 | 219 | } |
@@ -179,7 +179,8 @@ discard block |
||
179 | 179 | // does the adapter have an IP address? |
180 | 180 | try { |
181 | 181 | $ipAddress = $netifaces->getIpAddress($adapterToTest); |
182 | - } catch(NetifacesException $e){ |
|
182 | + } |
|
183 | + catch(NetifacesException $e) { |
|
183 | 184 | // We couldn't get an IP address |
184 | 185 | $ipAddress = null; |
185 | 186 | } |
@@ -213,7 +214,8 @@ discard block |
||
213 | 214 | // this sucks |
214 | 215 | throw new NetifacesException("Unable to determine IP address"); |
215 | 216 | |
216 | - } catch (NetifacesException $e){ |
|
217 | + } |
|
218 | + catch (NetifacesException $e) { |
|
217 | 219 | throw new Exception("could not determine IP address of host machine"); |
218 | 220 | } |
219 | 221 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * how should we provision this environment? |
222 | 222 | * |
223 | - * @return array<ProvisioningAdapters> |
|
223 | + * @return ProvisioningAdapter[] |
|
224 | 224 | */ |
225 | 225 | public function getProvisioningAdapters() |
226 | 226 | { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | /** |
266 | 266 | * what hosts exist in this group? |
267 | 267 | * |
268 | - * @return array<TestEnvironment_HostDefinition> |
|
268 | + * @return TestEnvironmentHost[] |
|
269 | 269 | */ |
270 | 270 | public function getHosts() |
271 | 271 | { |
@@ -74,6 +74,9 @@ |
||
74 | 74 | */ |
75 | 75 | protected $storySettings; |
76 | 76 | |
77 | + /** |
|
78 | + * @param string $hostId |
|
79 | + */ |
|
77 | 80 | public function __construct(TestEnvironment_GroupDefinition $parentGroup, $hostId) |
78 | 81 | { |
79 | 82 | $this->setParentGroup($parentGroup); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * this function avoids reset()ing the array, so it will not mess with |
54 | 54 | * any iteration that you may currently be part-way through |
55 | 55 | * |
56 | - * @param array $arrayToSearch |
|
56 | + * @param Storyplayer\TestEnvironments\ProvisioningAdapter[] $arrayToSearch |
|
57 | 57 | * the array to get the first element of |
58 | 58 | * @return mixed |
59 | 59 | * the first element of $array, or NULL if the array is empty |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * Create a new test environment object |
97 | 97 | * |
98 | - * @return TestEnvironment |
|
98 | + * @return TestEnvironment_Definition |
|
99 | 99 | * the test environment object to use in the script |
100 | 100 | */ |
101 | 101 | function newTestEnvironment() |
@@ -115,7 +115,8 @@ |
||
115 | 115 | * @param callback $callback the action(s) to attempt |
116 | 116 | * @return void |
117 | 117 | */ |
118 | -function tryTo($callback) { |
|
118 | +function tryTo($callback) |
|
119 | +{ |
|
119 | 120 | try { |
120 | 121 | $callback(); |
121 | 122 | } |
@@ -177,7 +177,6 @@ |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | - * @param integer $level |
|
181 | 180 | * @param string $msg |
182 | 181 | * @return void |
183 | 182 | */ |
@@ -99,6 +99,9 @@ |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | |
102 | + /** |
|
103 | + * @return string |
|
104 | + */ |
|
102 | 105 | public function getPublicDnsName() |
103 | 106 | { |
104 | 107 | // make sure we have a host to work with |
@@ -62,6 +62,10 @@ |
||
62 | 62 | */ |
63 | 63 | class FromPDOStatement extends Prose |
64 | 64 | { |
65 | + /** |
|
66 | + * @param \DataSift\Storyplayer\PlayerLib\StoryTeller $st |
|
67 | + * @param PDOStatement[] $args |
|
68 | + */ |
|
65 | 69 | public function __construct($st, $args) |
66 | 70 | { |
67 | 71 | // call our parent first |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | // what are we doing? |
82 | 82 | $log = usingLog()->startAction("fetch all rows from the PDO query result"); |
83 | 83 | |
84 | - try |
|
85 | - { |
|
84 | + try { |
|
86 | 85 | $rows = $this->args[0]->fetchAll(); |
87 | 86 | |
88 | 87 | // all done |
@@ -90,8 +89,7 @@ discard block |
||
90 | 89 | |
91 | 90 | return $rows; |
92 | 91 | } |
93 | - catch (Exception $e) |
|
94 | - { |
|
92 | + catch (Exception $e) { |
|
95 | 93 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
96 | 94 | } |
97 | 95 | } |
@@ -101,8 +99,7 @@ discard block |
||
101 | 99 | // what are we doing? |
102 | 100 | $log = usingLog()->startAction("fetch 1 row from the PDO query result"); |
103 | 101 | |
104 | - try |
|
105 | - { |
|
102 | + try { |
|
106 | 103 | $row = $this->args[0]->fetch(PDO::FETCH_ASSOC); |
107 | 104 | |
108 | 105 | // all done |
@@ -110,8 +107,7 @@ discard block |
||
110 | 107 | |
111 | 108 | return $row; |
112 | 109 | } |
113 | - catch (Exception $e) |
|
114 | - { |
|
110 | + catch (Exception $e) { |
|
115 | 111 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
116 | 112 | } |
117 | 113 | } |
@@ -121,8 +117,7 @@ discard block |
||
121 | 117 | // what are we doing? |
122 | 118 | $log = usingLog()->startAction("fetch 1 row from the PDO query result"); |
123 | 119 | |
124 | - try |
|
125 | - { |
|
120 | + try { |
|
126 | 121 | $row = $this->args[0]->fetch(PDO::FETCH_NUM); |
127 | 122 | |
128 | 123 | // all done |
@@ -130,8 +125,7 @@ discard block |
||
130 | 125 | |
131 | 126 | return $row; |
132 | 127 | } |
133 | - catch (Exception $e) |
|
134 | - { |
|
128 | + catch (Exception $e) { |
|
135 | 129 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
136 | 130 | } |
137 | 131 | } |
@@ -141,8 +135,7 @@ discard block |
||
141 | 135 | // what are we doing? |
142 | 136 | $log = usingLog()->startAction("fetch 1 row from the PDO query result"); |
143 | 137 | |
144 | - try |
|
145 | - { |
|
138 | + try { |
|
146 | 139 | $row = $this->args[0]->fetch(PDO::FETCH_OBJ); |
147 | 140 | |
148 | 141 | // all done |
@@ -150,8 +143,7 @@ discard block |
||
150 | 143 | |
151 | 144 | return $row; |
152 | 145 | } |
153 | - catch (Exception $e) |
|
154 | - { |
|
146 | + catch (Exception $e) { |
|
155 | 147 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
156 | 148 | } |
157 | 149 | } |
@@ -125,6 +125,9 @@ discard block |
||
125 | 125 | return $value; |
126 | 126 | } |
127 | 127 | |
128 | + /** |
|
129 | + * @param string $setting |
|
130 | + */ |
|
128 | 131 | public function getModuleSetting($setting) |
129 | 132 | { |
130 | 133 | // what are we doing? |
@@ -154,7 +157,7 @@ discard block |
||
154 | 157 | * We've standardised on 'getConfig()' as the documented name for this |
155 | 158 | * functionality across all three of the config-related modules. |
156 | 159 | * |
157 | - * @return object |
|
160 | + * @return string |
|
158 | 161 | */ |
159 | 162 | public function getAllSettings() |
160 | 163 | { |
@@ -132,7 +132,7 @@ |
||
132 | 132 | |
133 | 133 | // get the details |
134 | 134 | $fullPath = 'target.moduleSettings.' . $setting; |
135 | - $config = $this->st->getConfig(); |
|
135 | + $config = $this->st->getConfig(); |
|
136 | 136 | |
137 | 137 | $value = null; |
138 | 138 | if ($config->hasData($fullPath)) { |
@@ -62,6 +62,10 @@ |
||
62 | 62 | */ |
63 | 63 | class UsingPDODB extends Prose |
64 | 64 | { |
65 | + /** |
|
66 | + * @param \DataSift\Storyplayer\PlayerLib\StoryTeller $st |
|
67 | + * @param PDO[] $args |
|
68 | + */ |
|
65 | 69 | public function __construct($st, $args) |
66 | 70 | { |
67 | 71 | // call our parent first |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | // what are we doing? |
82 | 82 | $log = usingLog()->startAction(["run SQL query:", $sql, "/ with params:", $params, "and driver params:", $driverParams]); |
83 | 83 | |
84 | - try |
|
85 | - { |
|
84 | + try { |
|
86 | 85 | // create a prepared statement |
87 | 86 | // |
88 | 87 | // we do this so that we can inject the $params into the SQL statement |
@@ -95,8 +94,7 @@ discard block |
||
95 | 94 | $log->endAction(); |
96 | 95 | return $stmt; |
97 | 96 | } |
98 | - catch (Exception $e) |
|
99 | - { |
|
97 | + catch (Exception $e) { |
|
100 | 98 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
101 | 99 | } |
102 | 100 | } |
@@ -106,8 +104,7 @@ discard block |
||
106 | 104 | // what are we doing? |
107 | 105 | $log = usingLog()->startAction(["run raw SQL query:", $sql, "with driver params: ", $driverParams]); |
108 | 106 | |
109 | - try |
|
110 | - { |
|
107 | + try { |
|
111 | 108 | // execute the prepared statement |
112 | 109 | // |
113 | 110 | // we do this directly so that you can (hopefully) attempt |
@@ -118,8 +115,7 @@ discard block |
||
118 | 115 | $log->endAction(); |
119 | 116 | return $stmt; |
120 | 117 | } |
121 | - catch (Exception $e) |
|
122 | - { |
|
118 | + catch (Exception $e) { |
|
123 | 119 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
124 | 120 | } |
125 | 121 | } |
@@ -129,15 +125,13 @@ discard block |
||
129 | 125 | // what are we doing? |
130 | 126 | $log = usingLog()->startAction("begin PDO database transaction"); |
131 | 127 | |
132 | - try |
|
133 | - { |
|
128 | + try { |
|
134 | 129 | $this->args[0]->beginTransaction(); |
135 | 130 | |
136 | 131 | // all done |
137 | 132 | $log->endAction(); |
138 | 133 | } |
139 | - catch (Exception $e) |
|
140 | - { |
|
134 | + catch (Exception $e) { |
|
141 | 135 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
142 | 136 | } |
143 | 137 | } |
@@ -147,15 +141,13 @@ discard block |
||
147 | 141 | // what are we doing? |
148 | 142 | $log = usingLog()->startAction("commit PDO database transaction"); |
149 | 143 | |
150 | - try |
|
151 | - { |
|
144 | + try { |
|
152 | 145 | $this->args[0]->commit(); |
153 | 146 | |
154 | 147 | // all done |
155 | 148 | $log->endAction(); |
156 | 149 | } |
157 | - catch (Exception $e) |
|
158 | - { |
|
150 | + catch (Exception $e) { |
|
159 | 151 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
160 | 152 | } |
161 | 153 | } |
@@ -165,15 +157,13 @@ discard block |
||
165 | 157 | // what are we doing? |
166 | 158 | $log = usingLog()->startAction("rollback PDO database transaction"); |
167 | 159 | |
168 | - try |
|
169 | - { |
|
160 | + try { |
|
170 | 161 | $this->args[0]->rollBack(); |
171 | 162 | |
172 | 163 | // all done |
173 | 164 | $log->endAction(); |
174 | 165 | } |
175 | - catch (Exception $e) |
|
176 | - { |
|
166 | + catch (Exception $e) { |
|
177 | 167 | throw new E5xx_ActionFailed(__METHOD__, $e->getMessage()); |
178 | 168 | } |
179 | 169 | } |