Skip to content

Commit 7342b94

Browse files
committed
options validation test
1 parent d9c8cf5 commit 7342b94

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/Cleaner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function validateOptions()
2323
{
2424
if ($this->limit <= 0) {
2525
$message = sprintf(
26-
'limit expects a strictly positive TTL. Got %d.',
26+
'Limit expects a strictly positive. Got %d.',
2727
$this->limit
2828
);
2929
throw new InvalidArgumentException($message);

src/TarantoolStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function validateOptions()
3333
{
3434
if ($this->initialTtl <= 0) {
3535
$message = sprintf(
36-
'initialTtl expects a strictly positive TTL. Got %d.',
36+
'InitialTtl expects a strictly positive TTL. Got %d.',
3737
$this->initialTtl
3838
);
3939
throw new InvalidTtlException($message);

tests/TarantoolStoreTest.php

+50
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Tarantool\SymfonyLock\Tests;
44

5+
use InvalidArgumentException;
56
use PHPUnit\Framework\TestCase;
7+
use Symfony\Component\Lock\Exception\InvalidTtlException;
68
use Symfony\Component\Lock\Exception\LockConflictedException;
79
use Symfony\Component\Lock\Key;
810
use Symfony\Component\Lock\PersistingStoreInterface;
@@ -188,4 +190,52 @@ public function testCleanerLimit()
188190
$this->assertSame(0, $cleaner->process());
189191
$this->assertCount(1, $space->select(Criteria::key([])));
190192
}
193+
194+
public function testSchemaInvalidEngine()
195+
{
196+
$this->expectException(InvalidArgumentException::class);
197+
$this->expectExceptionMessage("Engine should be defined");
198+
199+
new SchemaManager(Client::fromDefaults(), [ 'engine' => '' ]);
200+
}
201+
202+
public function testSchemaInvalidSpaceName()
203+
{
204+
$this->expectException(InvalidArgumentException::class);
205+
$this->expectExceptionMessage("Space should be defined");
206+
207+
new SchemaManager(Client::fromDefaults(), [ 'space' => '' ]);
208+
}
209+
210+
public function testCleanerInvalidLimit()
211+
{
212+
$this->expectException(InvalidArgumentException::class);
213+
$this->expectExceptionMessage("Limit expects a strictly positive. Got 0");
214+
215+
new Cleaner(Client::fromDefaults(), [ 'limit' => 0 ]);
216+
}
217+
218+
public function testCleanerInvalidSpaceName()
219+
{
220+
$this->expectException(InvalidArgumentException::class);
221+
$this->expectExceptionMessage("Space should be defined");
222+
223+
new Cleaner(Client::fromDefaults(), [ 'space' => '' ]);
224+
}
225+
226+
public function testStoreInvalidTtl()
227+
{
228+
$this->expectException(InvalidTtlException::class);
229+
$this->expectExceptionMessage("InitialTtl expects a strictly positive TTL. Got 0.");
230+
231+
new TarantoolStore(Client::fromDefaults(), [ 'initialTtl' => 0 ]);
232+
}
233+
234+
public function testStoreInvalidSpaceName()
235+
{
236+
$this->expectException(InvalidArgumentException::class);
237+
$this->expectExceptionMessage("Space should be defined");
238+
239+
new TarantoolStore(Client::fromDefaults(), [ 'space' => '' ]);
240+
}
191241
}

0 commit comments

Comments
 (0)