init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\FreeGift\Test\Unit\Model;
|
||||
|
||||
use Esun\FreeGift\Model\InternalAddGuard;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InternalAddGuardTest extends TestCase
|
||||
{
|
||||
public function testExecuteAllowsOnlyTheWrappedCallback(): void
|
||||
{
|
||||
$guard = new InternalAddGuard();
|
||||
|
||||
self::assertFalse($guard->isAllowed());
|
||||
self::assertTrue($guard->execute(static fn (): bool => $guard->isAllowed()));
|
||||
self::assertFalse($guard->isAllowed());
|
||||
}
|
||||
|
||||
public function testGuardIsResetWhenCallbackThrows(): void
|
||||
{
|
||||
$guard = new InternalAddGuard();
|
||||
|
||||
try {
|
||||
$guard->execute(static function (): void {
|
||||
throw new \RuntimeException('Expected test exception');
|
||||
});
|
||||
} catch (\RuntimeException) {
|
||||
self::assertFalse($guard->isAllowed());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user