Skip to content

Commit 61c1c66

Browse files
committed
add test decorator
1 parent 9c616df commit 61c1c66

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/Units/Service/StorageTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Bavix\Wallet\Test\Units\Service;
66

7+
use Bavix\Wallet\Internal\Decorator\StorageServiceLockDecorator;
78
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
89
use Bavix\Wallet\Internal\Exceptions\RecordNotFoundException;
910
use Bavix\Wallet\Internal\Service\StorageServiceInterface;
@@ -28,4 +29,19 @@ public function testFlush(): void
2829

2930
$storage->get('hello'); // record not found
3031
}
32+
33+
public function testDecorator(): void
34+
{
35+
$this->expectException(RecordNotFoundException::class);
36+
$this->expectExceptionCode(ExceptionInterface::RECORD_NOT_FOUND);
37+
$storage = app(StorageServiceLockDecorator::class);
38+
39+
self::assertTrue($storage->sync('hello', 34));
40+
self::assertTrue($storage->sync('world', 42));
41+
self::assertSame('42', $storage->get('world'));
42+
self::assertSame('34', $storage->get('hello'));
43+
self::assertTrue($storage->flush());
44+
45+
$storage->get('hello'); // record not found
46+
}
3147
}

0 commit comments

Comments
 (0)