|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Gabievi\Promocodes\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Promocodes; |
|
6
|
|
|
|
|
7
|
|
|
class OutputRandomPromocodesTest extends TestCase |
|
|
|
|
|
|
8
|
|
|
{ |
|
9
|
|
|
/** @test */ |
|
10
|
|
|
public function it_will_output_only_one_code_without_parameter() |
|
11
|
|
|
{ |
|
12
|
|
|
$promocodes = Promocodes::output(); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertCount(1, $promocodes); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** @test */ |
|
18
|
|
|
public function it_can_output_several_promocodes_as_array() |
|
19
|
|
|
{ |
|
20
|
|
|
$promocodes = Promocodes::output(10); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertCount(10, $promocodes); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** @test */ |
|
26
|
|
|
public function it_can_output_several_promocodes_with_prefix_as_array() |
|
27
|
|
|
{ |
|
28
|
|
|
$promocodes = Promocodes::setPrefix('TEST')->output(10); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertCount(10, $promocodes); |
|
31
|
|
|
$this->assertStringStartsWith('TEST', $promocodes[0]); |
|
32
|
|
|
$this->assertStringStartsWith('TEST', $promocodes[9]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** @test */ |
|
36
|
|
|
public function it_can_output_several_promocodes_with_suffix_as_array() |
|
37
|
|
|
{ |
|
38
|
|
|
$promocodes = Promocodes::setSuffix('END')->output(10); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertCount(10, $promocodes); |
|
41
|
|
|
$this->assertStringEndsWith('END', $promocodes[0]); |
|
42
|
|
|
$this->assertStringEndsWith('END', $promocodes[9]); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** @test */ |
|
46
|
|
|
public function it_can_output_several_promocodes_with_prefix_and_suffix_as_array() |
|
47
|
|
|
{ |
|
48
|
|
|
$promocodes = Promocodes::setPrefix('ABC')->setSuffix('XYZ')->output(10); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertCount(10, $promocodes); |
|
51
|
|
|
$this->assertStringStartsWith('ABC', $promocodes[0]); |
|
52
|
|
|
$this->assertStringStartsWith('ABC', $promocodes[9]); |
|
53
|
|
|
$this->assertStringEndsWith('XYZ', $promocodes[0]); |
|
54
|
|
|
$this->assertStringEndsWith('XYZ', $promocodes[9]); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|