Rewrite parts of Predis\Transaction\MultiExec to make them less ugly.

We also changed some options for this class, the accepted ones are:

  - "keys": string or array of strings for automatic WATCH.
  - "cas": sets the check-and-set mode.
  - "retry": number of attempts before giving up aborted transactions.
  - "exceptions": sets whether exceptions should be thrown on error
    responses (overrides the "exceptions" client option).

The "on_retry" option has been removed.
This commit is contained in:
Daniele Alessandri
2013-11-17 13:59:35 +01:00
parent 84e0f5af7a
commit 712e6420e9
3 changed files with 109 additions and 71 deletions
+7 -3
View File
@@ -666,6 +666,7 @@ class ClientTest extends StandardTestCase
/**
* @group disconnected
* @todo I hate this test but reflection is the easiest way in this case.
*/
public function testTransactionWithArrayReturnsTransactionMultiExecWithOptions()
{
@@ -675,10 +676,13 @@ class ClientTest extends StandardTestCase
$this->assertInstanceOf('Predis\Transaction\MultiExec', $tx = $client->transaction($options));
$reflection = new \ReflectionProperty($tx, 'options');
$reflection->setAccessible(true);
$property = new \ReflectionProperty($tx, 'modeCAS');
$property->setAccessible(true);
$this->assertSame($options['cas'], $property->getValue($tx));
$this->assertSame($options, $reflection->getValue($tx));
$property = new \ReflectionProperty($tx, 'attempts');
$property->setAccessible(true);
$this->assertSame($options['retry'], $property->getValue($tx));
}
/**