123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace YdbPlatform\Ydb\Test;
- use PHPUnit\Framework\TestCase;
- use Ydb\Table\OnlineModeSettings;
- use Ydb\Table\SnapshotModeSettings;
- use Ydb\Table\StaleModeSettings;
- class CheckTxSettingsTest extends TestCase
- {
- public function testCheckParseTxMode()
- {
- $tests = [
- ['mode' => 'stale_read_only', 'result' => ['stale_read_only' => new StaleModeSettings]],
- ['mode' => 'stale', 'result' => ['stale_read_only' => new StaleModeSettings]],
- ['mode' => 'online_read_only', 'result' => ['online_read_only' => new OnlineModeSettings([
- 'allow_inconsistent_reads' => false,
- ])]],
- ['mode' => 'online', 'result' => ['online_read_only' => new OnlineModeSettings([
- 'allow_inconsistent_reads' => false,
- ])]],
- ['mode' => 'inconsistent_reads', 'result' => ['online_read_only' => new OnlineModeSettings([
- 'allow_inconsistent_reads' => true,
- ])]],
- ['mode' => 'online_inconsistent', 'result' => ['online_read_only' => new OnlineModeSettings([
- 'allow_inconsistent_reads' => true,
- ])]],
- ['mode' => 'online_inconsistent_reads', 'result' => ['online_read_only' => new OnlineModeSettings([
- 'allow_inconsistent_reads' => true,
- ])]],
- ['mode' => 'snapshot', 'result' => ['snapshot_read_only' => new SnapshotModeSettings]],
- ['mode' => 'snapshot_read_only', 'result' => ['snapshot_read_only' => new SnapshotModeSettings]],
- ];
- foreach ($tests as $i => $test){
- self::assertEquals($test["result"], Session::parseTxMode($test["mode"]));
- }
- self::expectException('Exception');
- Session::parseTxMode(null);
- }
- }
- class Session extends \YdbPlatform\Ydb\Session {
- public static function parseTxMode(string $mode = null): array
- {
- return parent::parseTxMode($mode);
- }
- }
|