소스 검색

Move classes related to MULTI/EXEC abstraction to the Predis\Transaction namespace.

Daniele Alessandri 13 년 전
부모
커밋
6ad73c782a

+ 0 - 7
lib/Predis/AbortedMultiExec.php

@@ -1,7 +0,0 @@
-<?php
-
-namespace Predis;
-
-class AbortedMultiExec extends PredisException {
-    // Aborted MULTI/EXEC transactions
-}

+ 1 - 0
lib/Predis/Client.php

@@ -8,6 +8,7 @@ use Predis\Network\IConnectionSingle;
 use Predis\Profiles\IServerProfile;
 use Predis\Profiles\ServerProfile;
 use Predis\Pipeline\PipelineContext;
+use Predis\Transaction\MultiExecContext;
 
 class Client {
     const VERSION = '0.7.0-dev';

+ 9 - 0
lib/Predis/Transaction/AbortedMultiExecException.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace Predis\Transaction;
+
+use Predis\PredisException;
+
+class AbortedMultiExecException extends PredisException {
+    // Aborted MULTI/EXEC transactions
+}

+ 10 - 2
lib/Predis/MultiExecContext.php → lib/Predis/Transaction/MultiExecContext.php

@@ -1,6 +1,14 @@
 <?php
 
-namespace Predis;
+namespace Predis\Transaction;
+
+use Predis\Client;
+use Predis\Helpers;
+use Predis\ResponseQueued;
+use Predis\ClientException;
+use Predis\ServerException;
+use Predis\ProtocolException;
+use Predis\CommunicationException;
 
 class MultiExecContext {
     private $_initialized, $_discarded, $_insideBlock, $_checkAndSet, $_watchedKeys;
@@ -186,7 +194,7 @@ class MultiExecContext {
             $reply = $this->_client->exec();
             if ($reply === null) {
                 if ($attemptsLeft === 0) {
-                    throw new AbortedMultiExec(
+                    throw new AbortedMultiExecException(
                         'The current transaction has been aborted by the server'
                     );
                 }

+ 6 - 5
test/ClientFeaturesTest.php

@@ -486,14 +486,15 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         $client->flushdb();
 
         $multi = $client->multiExec();
+        $transactionClass = '\Predis\Transaction\MultiExecContext';
 
-        $this->assertInstanceOf('\Predis\MultiExecContext', $multi);
-        $this->assertInstanceOf('\Predis\MultiExecContext', $multi->set('foo', 'bar'));
-        $this->assertInstanceOf('\Predis\MultiExecContext', $multi->set('hoge', 'piyo'));
-        $this->assertInstanceOf('\Predis\MultiExecContext', $multi->mset(array(
+        $this->assertInstanceOf($transactionClass, $multi);
+        $this->assertInstanceOf($transactionClass, $multi->set('foo', 'bar'));
+        $this->assertInstanceOf($transactionClass, $multi->set('hoge', 'piyo'));
+        $this->assertInstanceOf($transactionClass, $multi->mset(array(
             'foofoo' => 'barbar', 'hogehoge' => 'piyopiyo'
         )));
-        $this->assertInstanceOf('\Predis\MultiExecContext', $multi->mget(array(
+        $this->assertInstanceOf($transactionClass, $multi->mget(array(
             'foo', 'hoge', 'foofoo', 'hogehoge'
         )));
 

+ 2 - 2
test/PredisShared.php

@@ -168,10 +168,10 @@ class RC {
         try {
             $wrapFunction($testcaseInstance);
         }
-        catch (Predis\AbortedMultiExec $exception) {
+        catch (Predis\Transaction\AbortedMultiExecException $exception) {
             $thrownException = $exception;
         }
-        $testcaseInstance->assertInstanceOf('Predis\AbortedMultiExec', $thrownException);
+        $testcaseInstance->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $thrownException);
     }
 
     public static function pushTailAndReturn(Predis\Client $client, $keyName, Array $values, $wipeOut = 0) {