CheckParamsInRetryTransactionTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace YdbPlatform\Ydb\Test;
  3. use PHPUnit\Framework\TestCase;
  4. use YdbPlatform\Ydb\Exception;
  5. use YdbPlatform\Ydb\Retry\RetryParams;
  6. use YdbPlatform\Ydb\Session;
  7. use YdbPlatform\Ydb\Ydb;
  8. use YdbPlatform\Ydb\YdbTable;
  9. class CheckParamsInRetryTransactionTest extends TestCase
  10. {
  11. public function testCheckThrowExceptionsInRetryTransaction()
  12. {
  13. $config = [
  14. // Database path
  15. 'database' => '/local',
  16. // Database endpoint
  17. 'endpoint' => 'localhost:2136',
  18. // Auto discovery (dedicated server only)
  19. 'discovery' => false,
  20. // IAM config
  21. 'iam_config' => [
  22. 'anonymous' => true,
  23. 'insecure' => true
  24. ],
  25. ];
  26. $ydb = new Ydb($config);
  27. $table = $ydb->table();
  28. try {
  29. $table->retryTransaction(function (Session $session){}, true, null, ['idempotent'=>true]);
  30. throw new \Exception('retryTransaction does not throw exception');
  31. } catch (\YdbPlatform\Ydb\Exception $e){
  32. self::assertEquals(1,1);
  33. }
  34. try {
  35. $table->retryTransaction(function (Session $session){}, null, new RetryParams(), ['retryParams'=>new RetryParams()]);
  36. throw new \Exception('retryTransaction does not throw exception');
  37. } catch (\YdbPlatform\Ydb\Exception $e){
  38. self::assertEquals(1,1);
  39. }
  40. $table->retryTransaction(function (Session $session){});
  41. }
  42. }