Skip to content

Commit

Permalink
add test decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Sep 6, 2022
1 parent 9c616df commit 61c1c66
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Units/Service/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Bavix\Wallet\Test\Units\Service;

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

$storage->get('hello'); // record not found
}

public function testDecorator(): void
{
$this->expectException(RecordNotFoundException::class);
$this->expectExceptionCode(ExceptionInterface::RECORD_NOT_FOUND);
$storage = app(StorageServiceLockDecorator::class);

self::assertTrue($storage->sync('hello', 34));
self::assertTrue($storage->sync('world', 42));
self::assertSame('42', $storage->get('world'));
self::assertSame('34', $storage->get('hello'));
self::assertTrue($storage->flush());

$storage->get('hello'); // record not found
}
}

0 comments on commit 61c1c66

Please sign in to comment.