Skip to content

Commit

Permalink
Add test to make sure isAllowedToRedeemBy check works correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-rubel committed May 9, 2023
1 parent 7aeca3c commit b4d9f27
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/CouponsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ public function testCanVerifyCouponWhenSpecificModelAssigned()
Event::assertDispatched(CouponVerified::class);
}

/** @test */
public function testVerifyCouponThrowsExceptionWhenSpecificModelAssignedAndLimitIsSet()
{
$this->expectException(NotAllowedToRedeemException::class);

Coupon::create([
'code' => 'redeemer-coupon',
'redeemer_type' => $this->user::class,
'redeemer_id' => $this->user->id,
'limit' => 1,
'quantity' => 1,
]);

$redeemer = User::create([
'name' => 'Tester2',
'email' => 'test2@example.com',
'password' => Hash::make('pass2'),
]);

$redeemer->verifyCoupon('redeemer-coupon');
}

/** @test */
public function testCanRedeemCouponWhenSpecificModelAssigned()
{
Expand Down

0 comments on commit b4d9f27

Please sign in to comment.