@@ 41-52 (lines=12) @@ | ||
38 | } |
|
39 | ||
40 | /** @test */ |
|
41 | public function it_throws_exception_if_user_already_applied_to_code() |
|
42 | { |
|
43 | $this->expectException(AlreadyUsedException::class); |
|
44 | ||
45 | $promocodes = Promocodes::create(); |
|
46 | $promocode = $promocodes->first(); |
|
47 | ||
48 | $this->assertCount(1, $promocodes); |
|
49 | ||
50 | $this->user->applyCode($promocode['code']); |
|
51 | $this->user->applyCode($promocode['code']); |
|
52 | } |
|
53 | ||
54 | /** @test */ |
|
55 | public function it_attaches_current_user_as_applied_to_promocode() |
|
@@ 72-84 (lines=13) @@ | ||
69 | } |
|
70 | ||
71 | /** @test */ |
|
72 | public function is_returns_promocode_with_user_if_applied_successfuly() |
|
73 | { |
|
74 | $promocodes = Promocodes::create(); |
|
75 | $promocode = $promocodes->first(); |
|
76 | ||
77 | $this->assertCount(1, $promocodes); |
|
78 | ||
79 | $appliedPromocode = $this->user->applyCode($promocode['code']); |
|
80 | ||
81 | $this->assertTrue($appliedPromocode instanceof Promocode); |
|
82 | ||
83 | $this->assertCount(1, $appliedPromocode->users); |
|
84 | } |
|
85 | ||
86 | /** @test */ |
|
87 | public function is_returns_promocode_with_user_in_callback_if_applied_successfuly() |
|
@@ 87-97 (lines=11) @@ | ||
84 | } |
|
85 | ||
86 | /** @test */ |
|
87 | public function is_returns_promocode_with_user_in_callback_if_applied_successfuly() |
|
88 | { |
|
89 | $promocodes = Promocodes::create(); |
|
90 | $promocode = $promocodes->first(); |
|
91 | ||
92 | $this->assertCount(1, $promocodes); |
|
93 | ||
94 | $this->user->applyCode($promocode['code'], function ($appliedPromocode) { |
|
95 | $this->assertTrue($appliedPromocode instanceof Promocode); |
|
96 | }); |
|
97 | } |
|
98 | ||
99 | /** @test */ |
|
100 | public function it_has_alias_named_reedem_code() |