From 037b745c01afc2ae7c6fb8d9d252e9bc7c023b0c Mon Sep 17 00:00:00 2001 From: crynobone Date: Wed, 4 Jun 2014 22:04:20 +0800 Subject: [PATCH] Fixes code styling. Signed-off-by: crynobone --- src/Testbench/TestCase.php | 3 +- .../Traits/ApplicationClientTrait.php | 30 +++++++--- .../Traits/PHPUnitAssertionsTrait.php | 58 +++++++------------ 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/Testbench/TestCase.php b/src/Testbench/TestCase.php index 5440267..beae4d6 100644 --- a/src/Testbench/TestCase.php +++ b/src/Testbench/TestCase.php @@ -15,8 +15,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase */ public function setUp() { - if ( ! $this->app) - { + if (! $this->app) { $this->refreshApplication(); } } diff --git a/src/Testbench/Traits/ApplicationClientTrait.php b/src/Testbench/Traits/ApplicationClientTrait.php index 87a4402..4326705 100644 --- a/src/Testbench/Traits/ApplicationClientTrait.php +++ b/src/Testbench/Traits/ApplicationClientTrait.php @@ -88,8 +88,16 @@ public function callSecure() * @param bool $changeHistory * @return \Illuminate\Http\Response */ - public function action($method, $action, $wildcards = array(), $parameters = array(), $files = array(), $server = array(), $content = null, $changeHistory = true) - { + public function action( + $method, + $action, + $wildcards = array(), + $parameters = array(), + $files = array(), + $server = array(), + $content = null, + $changeHistory = true + ) { $uri = $this->app['url']->action($action, $wildcards, true); return $this->call($method, $uri, $parameters, $files, $server, $content, $changeHistory); @@ -108,8 +116,16 @@ public function action($method, $action, $wildcards = array(), $parameters = arr * @param bool $changeHistory * @return \Illuminate\Http\Response */ - public function route($method, $name, $routeParameters = array(), $parameters = array(), $files = array(), $server = array(), $content = null, $changeHistory = true) - { + public function route( + $method, + $name, + $routeParameters = array(), + $parameters = array(), + $files = array(), + $server = array(), + $content = null, + $changeHistory = true + ) { $uri = $this->app['url']->route($name, $routeParameters); return $this->call($method, $uri, $parameters, $files, $server, $content, $changeHistory); @@ -125,8 +141,7 @@ public function session(array $data) { $this->startSession(); - foreach ($data as $key => $value) - { + foreach ($data as $key => $value) { $this->app['session']->put($key, $value); } } @@ -150,8 +165,7 @@ public function flushSession() */ protected function startSession() { - if ( ! $this->app['session']->isStarted()) - { + if (! $this->app['session']->isStarted()) { $this->app['session']->start(); } } diff --git a/src/Testbench/Traits/PHPUnitAssertionsTrait.php b/src/Testbench/Traits/PHPUnitAssertionsTrait.php index bbf0cb0..0aa2c57 100644 --- a/src/Testbench/Traits/PHPUnitAssertionsTrait.php +++ b/src/Testbench/Traits/PHPUnitAssertionsTrait.php @@ -38,21 +38,19 @@ public function assertResponseStatus($code) */ public function assertViewHas($key, $value = null) { - if (is_array($key)) return $this->assertViewHasAll($key); + if (is_array($key)) { + return $this->assertViewHasAll($key); + } $response = $this->client->getResponse(); - if ( ! isset($response->original) || ! $response->original instanceof View) - { + if (! isset($response->original) || ! $response->original instanceof View) { return $this->assertTrue(false, 'The response was not a view.'); } - if (is_null($value)) - { + if (is_null($value)) { $this->assertArrayHasKey($key, $response->original->getData()); - } - else - { + } else { $this->assertEquals($value, $response->original->$key); } } @@ -65,14 +63,10 @@ public function assertViewHas($key, $value = null) */ public function assertViewHasAll(array $bindings) { - foreach ($bindings as $key => $value) - { - if (is_int($key)) - { + foreach ($bindings as $key => $value) { + if (is_int($key)) { $this->assertViewHas($value); - } - else - { + } else { $this->assertViewHas($key, $value); } } @@ -88,8 +82,7 @@ public function assertViewMissing($key) { $response = $this->client->getResponse(); - if ( ! isset($response->original) || ! $response->original instanceof View) - { + if (! isset($response->original) || ! $response->original instanceof View) { return $this->assertTrue(false, 'The response was not a view.'); } @@ -149,14 +142,13 @@ public function assertRedirectedToAction($name, $parameters = array(), $with = a */ public function assertSessionHas($key, $value = null) { - if (is_array($key)) return $this->assertSessionHasAll($key); + if (is_array($key)) { + return $this->assertSessionHasAll($key); + } - if (is_null($value)) - { + if (is_null($value)) { $this->assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); - } - else - { + } else { $this->assertEquals($value, $this->app['session.store']->get($key)); } } @@ -169,14 +161,10 @@ public function assertSessionHas($key, $value = null) */ public function assertSessionHasAll(array $bindings) { - foreach ($bindings as $key => $value) - { - if (is_int($key)) - { + foreach ($bindings as $key => $value) { + if (is_int($key)) { $this->assertSessionHas($value); - } - else - { + } else { $this->assertSessionHas($key, $value); } } @@ -197,14 +185,10 @@ public function assertSessionHasErrors($bindings = array(), $format = null) $errors = $this->app['session.store']->get('errors'); - foreach ($bindings as $key => $value) - { - if (is_int($key)) - { + foreach ($bindings as $key => $value) { + if (is_int($key)) { $this->assertTrue($errors->has($value), "Session missing error: $value"); - } - else - { + } else { $this->assertContains($value, $errors->get($key, $format)); } }