@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function __construct($name, Array $parameters = []) |
| 87 | 87 | { |
| 88 | - $this->name = $name; |
|
| 88 | + $this->name = $name; |
|
| 89 | 89 | $this->setParams($parameters); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | $_view = $this->path . DIRECTORY_SEPARATOR . $this->name . '.phtml'; |
| 102 | 102 | |
| 103 | 103 | if (!file_exists($_view)) |
| 104 | - throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists"); |
|
| 104 | + throw new Exception\ViewNotFoundException("The view '" . $this->name . "' does not exists"); |
|
| 105 | 105 | |
| 106 | 106 | $contents = file_get_contents($_view); |
| 107 | 107 | |
| 108 | 108 | if ($contents === false) |
| 109 | - throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists"); |
|
| 109 | + throw new Exception\ViewGetContentsErrorException("The view '" . $this->name . "' does not exists"); |
|
| 110 | 110 | |
| 111 | 111 | return $contents; |
| 112 | 112 | } |
@@ -100,13 +100,15 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $_view = $this->path . DIRECTORY_SEPARATOR . $this->name . '.phtml'; |
| 102 | 102 | |
| 103 | - if (!file_exists($_view)) |
|
| 104 | - throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists"); |
|
| 103 | + if (!file_exists($_view)) { |
|
| 104 | + throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists"); |
|
| 105 | + } |
|
| 105 | 106 | |
| 106 | 107 | $contents = file_get_contents($_view); |
| 107 | 108 | |
| 108 | - if ($contents === false) |
|
| 109 | - throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists"); |
|
| 109 | + if ($contents === false) { |
|
| 110 | + throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists"); |
|
| 111 | + } |
|
| 110 | 112 | |
| 111 | 113 | return $contents; |
| 112 | 114 | } |
@@ -118,8 +120,9 @@ discard block |
||
| 118 | 120 | */ |
| 119 | 121 | public function render() |
| 120 | 122 | { |
| 121 | - if (count($this->getParams())) |
|
| 122 | - extract($this->getParams(), EXTR_SKIP); |
|
| 123 | + if (count($this->getParams())) { |
|
| 124 | + extract($this->getParams(), EXTR_SKIP); |
|
| 125 | + } |
|
| 123 | 126 | |
| 124 | 127 | include $this->getContents(); |
| 125 | 128 | } |
@@ -263,11 +263,10 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | foreach ($this->routes as $key => $route) |
| 265 | 265 | { |
| 266 | - if |
|
| 267 | - ( |
|
| 268 | - $route["module"] == $this->identifiers["module"] && |
|
| 266 | + if ( |
|
| 267 | + $route["module"] == $this->identifiers["module"] && |
|
| 269 | 268 | $route["controller"] == $this->identifiers["controller"] && |
| 270 | - $route["view"] == $this->identifiers["view"] |
|
| 269 | + $route["view"] == $this->identifiers["view"] |
|
| 271 | 270 | ) |
| 272 | 271 | { |
| 273 | 272 | $module = $route["module"]; |
@@ -282,9 +281,8 @@ discard block |
||
| 282 | 281 | |
| 283 | 282 | if (count($this->defaults) && !$match) |
| 284 | 283 | { |
| 285 | - if |
|
| 286 | - ( |
|
| 287 | - !empty($this->defaults["module"]) && |
|
| 284 | + if ( |
|
| 285 | + !empty($this->defaults["module"]) && |
|
| 288 | 286 | !empty($this->defaults["controller"]) && |
| 289 | 287 | !empty($this->defaults["view"]) |
| 290 | 288 | ) |
@@ -100,8 +100,9 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function getController() |
| 102 | 102 | { |
| 103 | - if (is_null($this->controller)) |
|
| 104 | - throw new \RuntimeException("No controller matched, try to match first."); |
|
| 103 | + if (is_null($this->controller)) { |
|
| 104 | + throw new \RuntimeException("No controller matched, try to match first."); |
|
| 105 | + } |
|
| 105 | 106 | |
| 106 | 107 | return $this->controller; |
| 107 | 108 | } |
@@ -141,8 +142,9 @@ discard block |
||
| 141 | 142 | |
| 142 | 143 | foreach ($identifiers as $key => $identifier) |
| 143 | 144 | { |
| 144 | - if (!is_string($identifier)) |
|
| 145 | - throw new \InvalidArgumentException("Invalid type given for '$key'. String expected."); |
|
| 145 | + if (!is_string($identifier)) { |
|
| 146 | + throw new \InvalidArgumentException("Invalid type given for '$key'. String expected."); |
|
| 147 | + } |
|
| 146 | 148 | } |
| 147 | 149 | |
| 148 | 150 | $this->identifiers = [ |
@@ -167,8 +169,9 @@ discard block |
||
| 167 | 169 | |
| 168 | 170 | foreach ($identifiers as $key => $identifier) |
| 169 | 171 | { |
| 170 | - if (!is_string($identifier)) |
|
| 171 | - throw new \InvalidArgumentException("Invalid type given for '$key'. String expected."); |
|
| 172 | + if (!is_string($identifier)) { |
|
| 173 | + throw new \InvalidArgumentException("Invalid type given for '$key'. String expected."); |
|
| 174 | + } |
|
| 172 | 175 | } |
| 173 | 176 | |
| 174 | 177 | $this->defaults = [ |
@@ -237,8 +240,9 @@ discard block |
||
| 237 | 240 | */ |
| 238 | 241 | public function match() |
| 239 | 242 | { |
| 240 | - if (!is_callable($this->classNameBuilder)) |
|
| 241 | - throw \LogicException("No class name builder found"); |
|
| 243 | + if (!is_callable($this->classNameBuilder)) { |
|
| 244 | + throw \LogicException("No class name builder found"); |
|
| 245 | + } |
|
| 242 | 246 | |
| 243 | 247 | /* |
| 244 | 248 | * Key value pairs builder: |
@@ -297,8 +301,9 @@ discard block |
||
| 297 | 301 | } |
| 298 | 302 | } |
| 299 | 303 | |
| 300 | - if (!$match) |
|
| 301 | - throw new Exception\RouteNotFoundException("The route has not been matched"); |
|
| 304 | + if (!$match) { |
|
| 305 | + throw new Exception\RouteNotFoundException("The route has not been matched"); |
|
| 306 | + } |
|
| 302 | 307 | |
| 303 | 308 | $fqn_controller = call_user_func($this->classNameBuilder, $module, $controller); |
| 304 | 309 | |
@@ -312,17 +317,16 @@ discard block |
||
| 312 | 317 | catch (Exception\MethodNotFoundException $e) |
| 313 | 318 | { |
| 314 | 319 | throw new Exception\PageNotFoundException($e->getMessage(), $e->getCode(), $e); |
| 315 | - } |
|
| 316 | - catch (Exception\PrivateMethodExecutionException $e) |
|
| 320 | + } catch (Exception\PrivateMethodExecutionException $e) |
|
| 317 | 321 | { |
| 318 | 322 | throw new Exception\PageNotFoundException($e->getMessage(), $e->getCode(), $e); |
| 319 | 323 | } |
| 320 | 324 | |
| 321 | 325 | # in controller terms, a view is a method |
| 322 | 326 | $this->controller->setMethod($view); |
| 327 | + } else { |
|
| 328 | + throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!"); |
|
| 323 | 329 | } |
| 324 | - else |
|
| 325 | - throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!"); |
|
| 326 | 330 | } |
| 327 | 331 | |
| 328 | 332 | /** |
@@ -348,8 +352,9 @@ discard block |
||
| 348 | 352 | { |
| 349 | 353 | $key = array_keys($route); |
| 350 | 354 | |
| 351 | - if (count($key) > 1) |
|
| 352 | - throw new \InvalidArgumentException("So many keys in a simple route"); |
|
| 355 | + if (count($key) > 1) { |
|
| 356 | + throw new \InvalidArgumentException("So many keys in a simple route"); |
|
| 357 | + } |
|
| 353 | 358 | |
| 354 | 359 | $key = array_shift($key); |
| 355 | 360 | |
@@ -357,15 +362,18 @@ discard block |
||
| 357 | 362 | |
| 358 | 363 | foreach ($identifiers as $identifier) |
| 359 | 364 | { |
| 360 | - if (!array_key_exists($identifier, $route[$key])) |
|
| 361 | - throw new \InvalidArgumentException("The identifier '$identifier' does not exists in the route"); |
|
| 365 | + if (!array_key_exists($identifier, $route[$key])) { |
|
| 366 | + throw new \InvalidArgumentException("The identifier '$identifier' does not exists in the route"); |
|
| 367 | + } |
|
| 362 | 368 | |
| 363 | - if (!is_string($route[$key][$identifier])) |
|
| 364 | - throw new \InvalidArgumentException("Invalid type given for '$identifier'. String expected."); |
|
| 369 | + if (!is_string($route[$key][$identifier])) { |
|
| 370 | + throw new \InvalidArgumentException("Invalid type given for '$identifier'. String expected."); |
|
| 371 | + } |
|
| 365 | 372 | } |
| 366 | 373 | |
| 367 | - if (array_key_exists($key, $this->routes)) |
|
| 368 | - throw new \LogicException("The key '$key' was already defined as a route"); |
|
| 374 | + if (array_key_exists($key, $this->routes)) { |
|
| 375 | + throw new \LogicException("The key '$key' was already defined as a route"); |
|
| 376 | + } |
|
| 369 | 377 | |
| 370 | 378 | $this->routes = array_merge($this->routes, $route); |
| 371 | 379 | } |
@@ -406,10 +414,11 @@ discard block |
||
| 406 | 414 | $i = 1; |
| 407 | 415 | foreach ($params as $item) |
| 408 | 416 | { |
| 409 | - if ($i % 2 != 0) |
|
| 410 | - $vars[] = $item; |
|
| 411 | - else |
|
| 412 | - $values[] = $item; |
|
| 417 | + if ($i % 2 != 0) { |
|
| 418 | + $vars[] = $item; |
|
| 419 | + } else { |
|
| 420 | + $values[] = $item; |
|
| 421 | + } |
|
| 413 | 422 | $i++; |
| 414 | 423 | } |
| 415 | 424 | |
@@ -419,10 +428,11 @@ discard block |
||
| 419 | 428 | |
| 420 | 429 | for ($i = 0; $i < $vars_count; $i++) |
| 421 | 430 | { |
| 422 | - if (array_key_exists($i, $values)) |
|
| 423 | - $result[$vars[$i]] = $values[$i]; |
|
| 424 | - else |
|
| 425 | - $result[$vars[$i]] = ''; |
|
| 431 | + if (array_key_exists($i, $values)) { |
|
| 432 | + $result[$vars[$i]] = $values[$i]; |
|
| 433 | + } else { |
|
| 434 | + $result[$vars[$i]] = ''; |
|
| 435 | + } |
|
| 426 | 436 | } |
| 427 | 437 | |
| 428 | 438 | return $result; |
@@ -190,17 +190,17 @@ |
||
| 190 | 190 | */ |
| 191 | 191 | public function run() |
| 192 | 192 | { |
| 193 | - $module = isset($_GET["module"]) ? $_GET["module"] : null; |
|
| 193 | + $module = isset($_GET["module"]) ? $_GET["module"] : null; |
|
| 194 | 194 | $controller = isset($_GET["controller"]) ? $_GET["controller"] : null; |
| 195 | - $view = isset($_GET["view"]) ? $_GET["view"] : null; |
|
| 195 | + $view = isset($_GET["view"]) ? $_GET["view"] : null; |
|
| 196 | 196 | |
| 197 | 197 | $request = new \Zend\Http\Request(); |
| 198 | 198 | |
| 199 | 199 | # build URI |
| 200 | 200 | $uri = ''; |
| 201 | - $uri .= !empty($module) ? '/' . $module : ""; |
|
| 201 | + $uri .= !empty($module) ? '/' . $module : ""; |
|
| 202 | 202 | $uri .= !empty($controller) ? '/' . $controller : ""; |
| 203 | - $uri .= !empty($view) ? '/' . $view : ""; |
|
| 203 | + $uri .= !empty($view) ? '/' . $view : ""; |
|
| 204 | 204 | |
| 205 | 205 | if (empty($uri)) |
| 206 | 206 | $uri = "/"; |
@@ -99,19 +99,23 @@ discard block |
||
| 99 | 99 | public function __construct(Array $config) |
| 100 | 100 | { |
| 101 | 101 | # start sessions |
| 102 | - if (!isset($_SESSION)) |
|
| 103 | - session_start(); |
|
| 102 | + if (!isset($_SESSION)) { |
|
| 103 | + session_start(); |
|
| 104 | + } |
|
| 104 | 105 | |
| 105 | - if (!array_key_exists('environment', $config)) |
|
| 106 | - throw new \InvalidArgumentException("The 'environment' key was not defined"); |
|
| 106 | + if (!array_key_exists('environment', $config)) { |
|
| 107 | + throw new \InvalidArgumentException("The 'environment' key was not defined"); |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | - if (!array_key_exists('dev_mode', $config['environment'])) |
|
| 109 | - throw new \InvalidArgumentException("The 'dev_mode' key was not defined"); |
|
| 110 | + if (!array_key_exists('dev_mode', $config['environment'])) { |
|
| 111 | + throw new \InvalidArgumentException("The 'dev_mode' key was not defined"); |
|
| 112 | + } |
|
| 110 | 113 | |
| 111 | 114 | $this->devMode = $config["environment"]["dev_mode"]; |
| 112 | 115 | |
| 113 | - if (!array_key_exists('modules', $config)) |
|
| 114 | - throw new \InvalidArgumentException("The 'modules' key was not defined"); |
|
| 116 | + if (!array_key_exists('modules', $config)) { |
|
| 117 | + throw new \InvalidArgumentException("The 'modules' key was not defined"); |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | $this->modules = $config["modules"]; |
| 117 | 121 | |
@@ -125,33 +129,36 @@ discard block |
||
| 125 | 129 | { |
| 126 | 130 | ini_set('display_errors', 1); |
| 127 | 131 | error_reporting(-1); |
| 128 | - } |
|
| 129 | - else |
|
| 132 | + } else |
|
| 130 | 133 | { |
| 131 | 134 | ini_set('display_errors', 0); |
| 132 | 135 | error_reporting(0); |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | - if (!array_key_exists('router', $config)) |
|
| 136 | - throw new \InvalidArgumentException("The 'router' key was not defined"); |
|
| 138 | + if (!array_key_exists('router', $config)) { |
|
| 139 | + throw new \InvalidArgumentException("The 'router' key was not defined"); |
|
| 140 | + } |
|
| 137 | 141 | |
| 138 | - if (!array_key_exists('routes', $config["router"])) |
|
| 139 | - throw new \InvalidArgumentException("The 'routes' key was not defined"); |
|
| 142 | + if (!array_key_exists('routes', $config["router"])) { |
|
| 143 | + throw new \InvalidArgumentException("The 'routes' key was not defined"); |
|
| 144 | + } |
|
| 140 | 145 | |
| 141 | 146 | $this->router = new Router($config["router"]["routes"]); |
| 142 | 147 | |
| 143 | - if (!array_key_exists('base_path', $config['environment'])) |
|
| 144 | - throw new \InvalidArgumentException("The 'base_path' key was not defined"); |
|
| 148 | + if (!array_key_exists('base_path', $config['environment'])) { |
|
| 149 | + throw new \InvalidArgumentException("The 'base_path' key was not defined"); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | $this->basePath = $config["environment"]["base_path"]; |
| 147 | 153 | |
| 148 | 154 | # load routes from config |
| 149 | 155 | foreach ($config["router"]["routes"] as $name => $route) |
| 150 | 156 | { |
| 151 | - if ($route instanceof \Zend\Router\Http\RouteInterface) |
|
| 152 | - $this->router->addZendRoute($name, $route); |
|
| 153 | - else |
|
| 154 | - $this->router->addRoute($route); |
|
| 157 | + if ($route instanceof \Zend\Router\Http\RouteInterface) { |
|
| 158 | + $this->router->addZendRoute($name, $route); |
|
| 159 | + } else { |
|
| 160 | + $this->router->addRoute($route); |
|
| 161 | + } |
|
| 155 | 162 | } |
| 156 | 163 | |
| 157 | 164 | # register autoloading functions for each module |
@@ -172,11 +179,13 @@ discard block |
||
| 172 | 179 | { |
| 173 | 180 | $module_config_file = require($this->modulePath . "/$module/config/module.config.php"); |
| 174 | 181 | |
| 175 | - if (!array_key_exists('router', $module_config_file)) |
|
| 176 | - throw new \RuntimeException("The 'router' key was not defined in the config file for module '$module'"); |
|
| 182 | + if (!array_key_exists('router', $module_config_file)) { |
|
| 183 | + throw new \RuntimeException("The 'router' key was not defined in the config file for module '$module'"); |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | - if (!array_key_exists('routes', $module_config_file["router"])) |
|
| 179 | - throw new \RuntimeException("The 'routes' key was not defined in the config file for module '$module'"); |
|
| 186 | + if (!array_key_exists('routes', $module_config_file["router"])) { |
|
| 187 | + throw new \RuntimeException("The 'routes' key was not defined in the config file for module '$module'"); |
|
| 188 | + } |
|
| 180 | 189 | |
| 181 | 190 | $this->getRouter()->addRoute($module_config_file["router"]["routes"]); |
| 182 | 191 | } |
@@ -202,8 +211,9 @@ discard block |
||
| 202 | 211 | $uri .= !empty($controller) ? '/' . $controller : ""; |
| 203 | 212 | $uri .= !empty($view) ? '/' . $view : ""; |
| 204 | 213 | |
| 205 | - if (empty($uri)) |
|
| 206 | - $uri = "/"; |
|
| 214 | + if (empty($uri)) { |
|
| 215 | + $uri = "/"; |
|
| 216 | + } |
|
| 207 | 217 | |
| 208 | 218 | $request->setUri($uri); |
| 209 | 219 | |
@@ -219,9 +229,9 @@ discard block |
||
| 219 | 229 | $view = $params["action"]; |
| 220 | 230 | |
| 221 | 231 | $this->router->setIdentifiers($module, $controller, $view); |
| 232 | + } else { |
|
| 233 | + $this->router->setIdentifiers($module, $controller, $view); |
|
| 222 | 234 | } |
| 223 | - else |
|
| 224 | - $this->router->setIdentifiers($module, $controller, $view); |
|
| 225 | 235 | |
| 226 | 236 | $this->router->match(); |
| 227 | 237 | |
@@ -240,8 +250,9 @@ discard block |
||
| 240 | 250 | { |
| 241 | 251 | $result->setPath($this->basePath . DIRECTORY_SEPARATOR . $this->modulePath . DIRECTORY_SEPARATOR . 'source/view'); |
| 242 | 252 | |
| 243 | - if (is_null($result->getName())) |
|
| 244 | - $result->setView($router->getController()->getMethod()); |
|
| 253 | + if (is_null($result->getName())) { |
|
| 254 | + $result->setView($router->getController()->getMethod()); |
|
| 255 | + } |
|
| 245 | 256 | |
| 246 | 257 | $result->render(); |
| 247 | 258 | } |
@@ -141,8 +141,9 @@ |
||
| 141 | 141 | { |
| 142 | 142 | $_file = $this->configFile; |
| 143 | 143 | |
| 144 | - if (!file_exists($_file)) |
|
| 145 | - throw new \RuntimeException("The config file '$_file' does not exists"); |
|
| 144 | + if (!file_exists($_file)) { |
|
| 145 | + throw new \RuntimeException("The config file '$_file' does not exists"); |
|
| 146 | + } |
|
| 146 | 147 | |
| 147 | 148 | return (array) include $this->configFile; |
| 148 | 149 | } |
@@ -41,7 +41,8 @@ |
||
| 41 | 41 | |
| 42 | 42 | $class = $path . implode(DIRECTORY_SEPARATOR, $nm) . ".php"; |
| 43 | 43 | |
| 44 | - if (file_exists($class)) |
|
| 45 | - include $class; |
|
| 44 | + if (file_exists($class)) { |
|
| 45 | + include $class; |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | } |
| 48 | 49 | \ No newline at end of file |
@@ -68,12 +68,10 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | 70 | $router->match(); |
| 71 | - } |
|
| 72 | - catch (\Exception $e) |
|
| 71 | + } catch (\Exception $e) |
|
| 73 | 72 | { |
| 74 | 73 | $errorObject = ($e instanceof RouteNotFoundException); |
| 75 | - } |
|
| 76 | - finally |
|
| 74 | + } finally |
|
| 77 | 75 | { |
| 78 | 76 | $this->assertTrue($errorObject, $e->getMessage()); |
| 79 | 77 | } |
@@ -181,12 +179,10 @@ discard block |
||
| 181 | 179 | |
| 182 | 180 | try { |
| 183 | 181 | $router->run(); |
| 184 | - } |
|
| 185 | - catch (\Exception $e) |
|
| 182 | + } catch (\Exception $e) |
|
| 186 | 183 | { |
| 187 | 184 | $errorObject = ($e instanceof MethodExecutionNotAllowedException); |
| 188 | - } |
|
| 189 | - finally |
|
| 185 | + } finally |
|
| 190 | 186 | { |
| 191 | 187 | $this->assertTrue($errorObject, $e->getMessage()); |
| 192 | 188 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | public function testCannotEstablishConnection() |
| 133 | 133 | { |
| 134 | 134 | $options = $this->options; |
| 135 | - $options["dbhost"] = 'myserver'; // this server does not exists |
|
| 135 | + $options["dbhost"] = 'myserver'; // this server does not exists |
|
| 136 | 136 | |
| 137 | 137 | $conn = new MySQL($options); |
| 138 | 138 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $this->assertEquals(2, $conn->getNumFields()); |
| 260 | 260 | $this->assertEquals(0, $conn->getRowsAffected()); |
| 261 | 261 | |
| 262 | - $rowset = $conn->getArrayResult(); # array with results |
|
| 262 | + $rowset = $conn->getArrayResult(); # array with results |
|
| 263 | 263 | $row = array_shift($rowset); |
| 264 | 264 | |
| 265 | 265 | $this->assertArrayHasKey("ID", $row); |
@@ -286,12 +286,12 @@ discard block |
||
| 286 | 286 | $conn->execute($sql); |
| 287 | 287 | $rowcount = count($conn->getArrayResult()); |
| 288 | 288 | |
| 289 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
| 289 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
| 290 | 290 | |
| 291 | 291 | # properties modified by execute() method |
| 292 | 292 | $this->assertEquals(1, $conn->getNumRows()); |
| 293 | 293 | $this->assertEquals(2, $conn->getNumFields()); |
| 294 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 294 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 295 | 295 | |
| 296 | 296 | $this->assertTrue($conn->commit()); |
| 297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $conn->execute($sql); |
| 301 | 301 | $rowcount = count($conn->getArrayResult()); |
| 302 | 302 | |
| 303 | - $this->assertTrue(($rowcount === 1)); # the row is available |
|
| 303 | + $this->assertTrue(($rowcount === 1)); # the row is available |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -323,12 +323,12 @@ discard block |
||
| 323 | 323 | $conn->execute($sql); |
| 324 | 324 | $rowcount = count($conn->getArrayResult()); |
| 325 | 325 | |
| 326 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
| 326 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
| 327 | 327 | |
| 328 | 328 | # properties modified by execute() method |
| 329 | 329 | $this->assertEquals(1, $conn->getNumRows()); |
| 330 | 330 | $this->assertEquals(2, $conn->getNumFields()); |
| 331 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 331 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 332 | 332 | |
| 333 | 333 | $this->assertTrue($conn->rollback()); |
| 334 | 334 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $conn->execute($sql); |
| 338 | 338 | $rowcount = count($conn->getArrayResult()); |
| 339 | 339 | |
| 340 | - $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
| 340 | + $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | $conn->execute($sql); |
| 370 | 370 | $rowcount = count($conn->getArrayResult()); |
| 371 | 371 | |
| 372 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
| 372 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
| 373 | 373 | |
| 374 | 374 | # properties modified by execute() method |
| 375 | 375 | $this->assertEquals(4, $conn->getNumRows()); |
| 376 | 376 | $this->assertEquals(2, $conn->getNumFields()); |
| 377 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 377 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 378 | 378 | |
| 379 | 379 | $this->assertTrue($conn->commit()); |
| 380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | $conn->execute($sql); |
| 384 | 384 | $rowcount = count($conn->getArrayResult()); |
| 385 | 385 | |
| 386 | - $this->assertTrue(($rowcount === 4)); # the rows are available |
|
| 386 | + $this->assertTrue(($rowcount === 4)); # the rows are available |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -415,12 +415,12 @@ discard block |
||
| 415 | 415 | $conn->execute($sql); |
| 416 | 416 | $rowcount = count($conn->getArrayResult()); |
| 417 | 417 | |
| 418 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
| 418 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
| 419 | 419 | |
| 420 | 420 | # properties modified by execute() method |
| 421 | 421 | $this->assertEquals(4, $conn->getNumRows()); |
| 422 | 422 | $this->assertEquals(2, $conn->getNumFields()); |
| 423 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 423 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 424 | 424 | |
| 425 | 425 | $this->assertTrue($conn->rollback()); |
| 426 | 426 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $conn->execute($sql); |
| 430 | 430 | $rowcount = count($conn->getArrayResult()); |
| 431 | 431 | |
| 432 | - $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
| 432 | + $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
| 433 | 433 | $this->assertTrue(($rowcount === 0)); |
| 434 | 434 | } |
| 435 | 435 | |
@@ -461,12 +461,12 @@ discard block |
||
| 461 | 461 | $conn->execute($sql); |
| 462 | 462 | $rowcount = count($conn->getArrayResult()); |
| 463 | 463 | |
| 464 | - $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
| 464 | + $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
| 465 | 465 | |
| 466 | 466 | # properties modified by execute() method |
| 467 | 467 | $this->assertEquals(2, $conn->getNumRows()); |
| 468 | 468 | $this->assertEquals(2, $conn->getNumFields()); |
| 469 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 469 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
| 470 | 470 | |
| 471 | 471 | # ends the transaction |
| 472 | 472 | $conn->endTransaction(); |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $conn->execute($sql); |
| 477 | 477 | $rowcount = count($conn->getArrayResult()); |
| 478 | 478 | |
| 479 | - $this->assertTrue(($rowcount === 2)); # the row is available |
|
| 479 | + $this->assertTrue(($rowcount === 2)); # the row is available |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $conn->execute($sql); |
| 504 | 504 | |
| 505 | 505 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
| 506 | - $conn->execute($sql); # this throws the exception |
|
| 506 | + $conn->execute($sql); # this throws the exception |
|
| 507 | 507 | } |
| 508 | 508 | catch (InvalidQueryException $e) |
| 509 | 509 | { |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | $conn->execute($sql); |
| 520 | 520 | $rowcount = count($conn->getArrayResult()); |
| 521 | 521 | |
| 522 | - $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
| 522 | + $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
| 523 | 523 | |
| 524 | 524 | # remove all work |
| 525 | 525 | $conn->execute("DROP TABLE MYTABLE"); |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | try { |
| 83 | 83 | $conn->disconnect(); |
| 84 | - } |
|
| 85 | - catch (\Exception $e) |
|
| 84 | + } catch (\Exception $e) |
|
| 86 | 85 | { |
| 87 | 86 | $this->assertNotTrue($conn->isConnected()); |
| 88 | 87 | throw $e; |
@@ -116,8 +115,7 @@ discard block |
||
| 116 | 115 | |
| 117 | 116 | try { |
| 118 | 117 | $conn->reconnect(); |
| 119 | - } |
|
| 120 | - catch (\Exception $e) |
|
| 118 | + } catch (\Exception $e) |
|
| 121 | 119 | { |
| 122 | 120 | $this->assertNotTrue($conn->isConnected()); |
| 123 | 121 | throw $e; |
@@ -139,8 +137,7 @@ discard block |
||
| 139 | 137 | try |
| 140 | 138 | { |
| 141 | 139 | $conn->connect(); |
| 142 | - } |
|
| 143 | - catch (\Exception $e) |
|
| 140 | + } catch (\Exception $e) |
|
| 144 | 141 | { |
| 145 | 142 | $this->assertNotTrue($conn->isConnected()); |
| 146 | 143 | throw $e; |
@@ -504,8 +501,7 @@ discard block |
||
| 504 | 501 | |
| 505 | 502 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
| 506 | 503 | $conn->execute($sql); # this throws the exception |
| 507 | - } |
|
| 508 | - catch (InvalidQueryException $e) |
|
| 504 | + } catch (InvalidQueryException $e) |
|
| 509 | 505 | { |
| 510 | 506 | #·not necessary! |
| 511 | 507 | # $this->assertTrue($conn->rollback()); |