@@ 38-52 (lines=15) @@ | ||
35 | } |
|
36 | ||
37 | /** @test */ |
|
38 | public function it_throws_exception_if_user_tries_to_apply_code_twice() |
|
39 | { |
|
40 | $this->expectException(AlreadyUsedException::class); |
|
41 | ||
42 | $user = User::find(1); |
|
43 | $this->actingAs($user); |
|
44 | ||
45 | $promocodes = Promocodes::create(); |
|
46 | $promocode = $promocodes->first(); |
|
47 | ||
48 | $this->assertCount(1, $promocodes); |
|
49 | ||
50 | Promocodes::apply($promocode['code']); |
|
51 | Promocodes::apply($promocode['code']); |
|
52 | } |
|
53 | ||
54 | /** @test */ |
|
55 | public function it_attaches_authenticated_user_as_applied_to_promocode() |
|
@@ 93-106 (lines=14) @@ | ||
90 | } |
|
91 | ||
92 | /** @test */ |
|
93 | public function it_has_alias_named_reedem() |
|
94 | { |
|
95 | $user = User::find(1); |
|
96 | $this->actingAs($user); |
|
97 | ||
98 | $promocodes = Promocodes::create(); |
|
99 | $promocode = $promocodes->first(); |
|
100 | ||
101 | $this->assertCount(1, $promocodes); |
|
102 | ||
103 | Promocodes::redeem($promocode['code']); |
|
104 | ||
105 | $this->assertCount(1, $user->promocodes); |
|
106 | } |
|
107 | } |
|
108 |