|
9 | 9 | use Symfony\Component\Lock\Key;
|
10 | 10 | use Symfony\Component\Lock\PersistingStoreInterface;
|
11 | 11 | use Tarantool\Client\Client;
|
| 12 | +use Tarantool\Client\Exception\RequestFailed; |
12 | 13 | use Tarantool\Client\Schema\Criteria;
|
13 | 14 | use Tarantool\SymfonyLock\Cleaner;
|
14 | 15 | use Tarantool\SymfonyLock\SchemaManager;
|
@@ -238,4 +239,40 @@ public function testStoreInvalidSpaceName()
|
238 | 239 |
|
239 | 240 | new TarantoolStore(Client::fromDefaults(), [ 'space' => '' ]);
|
240 | 241 | }
|
| 242 | + |
| 243 | + public function testSuccessSchemaCreation() |
| 244 | + { |
| 245 | + $host = getenv('TARANTOOL_CONNECTION_HOST'); |
| 246 | + $port = getenv('TARANTOOL_CONNECTION_PORT'); |
| 247 | + |
| 248 | + $client = Client::fromDsn("tcp://$host:$port"); |
| 249 | + $client->evaluate('box.session.su("admin")'); |
| 250 | + |
| 251 | + $schema = new SchemaManager($client); |
| 252 | + $schema->tearDown(); |
| 253 | + |
| 254 | + $store = new TarantoolStore($client, [ 'createSchema' => true ]); |
| 255 | + $store->save(new Key(uniqid(__METHOD__, true))); |
| 256 | + |
| 257 | + $tuples = $this->client->getSpace('lock')->select(Criteria::key([])); |
| 258 | + $this->assertCount(1, $tuples); |
| 259 | + } |
| 260 | + |
| 261 | + public function testDefaultSchemaCreationIsDisabled() |
| 262 | + { |
| 263 | + $host = getenv('TARANTOOL_CONNECTION_HOST'); |
| 264 | + $port = getenv('TARANTOOL_CONNECTION_PORT'); |
| 265 | + |
| 266 | + $client = Client::fromDsn("tcp://$host:$port"); |
| 267 | + $client->evaluate('box.session.su("admin")'); |
| 268 | + |
| 269 | + $schema = new SchemaManager($client); |
| 270 | + $schema->tearDown(); |
| 271 | + |
| 272 | + $this->expectException(RequestFailed::class); |
| 273 | + $this->expectExceptionMessage("Space 'lock' does not exist"); |
| 274 | + |
| 275 | + $store = new TarantoolStore($client); |
| 276 | + $store->save(new Key(uniqid(__METHOD__, true))); |
| 277 | + } |
241 | 278 | }
|
0 commit comments