Quellcode durchsuchen

[tests] No need to reassign $exception.

Backported from 728d9dc (master).
Daniele Alessandri vor 11 Jahren
Ursprung
Commit
ad92618003

+ 12 - 6
tests/Predis/Pipeline/PipelineContextTest.php

@@ -253,6 +253,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testExecuteWithCallableArgumentHandlesExceptions()
     {
+        $exception = null;
+
         $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
         $connection->expects($this->never())->method('writeCommand');
         $connection->expects($this->never())->method('readResponse');
@@ -268,8 +270,8 @@ class PipelineContextTest extends PredisTestCase
                 throw new ClientException('TEST');
                 $pipe->echo('two');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -336,6 +338,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testIntegrationWithClientExceptionInCallableBlock()
     {
+        $exception = null;
+
         $client = $this->getClient();
 
         try {
@@ -343,8 +347,8 @@ class PipelineContextTest extends PredisTestCase
                 $pipe->set('foo', 'bar');
                 throw new ClientException('TEST');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -357,6 +361,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testIntegrationWithServerExceptionInCallableBlock()
     {
+        $exception = null;
+
         $client = $this->getClient();
 
         try {
@@ -367,8 +373,8 @@ class PipelineContextTest extends PredisTestCase
                 $pipe->lpush('foo', 'bar');
                 $pipe->set('hoge', 'piyo');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ServerException', $exception);

+ 19 - 12
tests/Predis/Transaction/MultiExecContextTest.php

@@ -89,6 +89,8 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testCannotMixExecutionWithFluentInterfaceAndCallable()
     {
+        $exception = null;
+
         $commands = array();
 
         $callback = $this->getExecuteCallback(null, $commands);
@@ -100,8 +102,8 @@ class MultiExecContextTest extends PredisTestCase
             $tx->echo('foo')->execute(function ($tx) {
                 $tx->echo('bar');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -419,6 +421,8 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testHandlesStandardExceptionsInBlock()
     {
+        $exception = null;
+
         $commands = array();
         $expected = array('foobar', true);
 
@@ -434,7 +438,7 @@ class MultiExecContextTest extends PredisTestCase
 
                 throw new \RuntimeException('TEST');
             });
-        } catch (\Exception $ex) {
+        } catch (\Exception $exception) {
             // NOOP
         }
 
@@ -461,7 +465,7 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->echo('ERR Invalid operation');
                 $tx->get('foo');
             });
-        } catch (ServerException $ex) {
+        } catch (ServerException $exception) {
             $tx->discard();
         }
 
@@ -478,16 +482,17 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testIntegrationHandlesStandardExceptionsInBlock()
     {
-        $client = $this->getClient();
         $exception = null;
 
+        $client = $this->getClient();
+
         try {
             $client->multiExec(function ($tx) {
                 $tx->set('foo', 'bar');
                 throw new \RuntimeException("TEST");
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('RuntimeException', $exception);
@@ -499,8 +504,9 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testIntegrationThrowsExceptionOnRedisErrorInBlock()
     {
-        $client = $this->getClient();
         $exception = null;
+
+        $client = $this->getClient();
         $value = (string) rand();
 
         try {
@@ -509,8 +515,8 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->lpush('foo', 'bar');
                 $tx->set('foo', $value);
             });
-        } catch (ServerException $ex) {
-            $exception = $ex;
+        } catch (ServerException $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception);
@@ -559,6 +565,7 @@ class MultiExecContextTest extends PredisTestCase
     public function testIntegrationWritesOnWatchedKeysAbortTransaction()
     {
         $exception = null;
+
         $client1 = $this->getClient();
         $client2 = $this->getClient();
 
@@ -568,8 +575,8 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->get('sentinel');
                 $client2->set('sentinel', 'client2');
             });
-        } catch (AbortedMultiExecException $ex) {
-            $exception = $ex;
+        } catch (AbortedMultiExecException $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception);