|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverCommerce\OrdersAdmin\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
6
|
|
|
use SilverCommerce\OrdersAdmin\Model\Invoice; |
|
7
|
|
|
use SilverCommerce\OrdersAdmin\Tests\Model\TestProduct; |
|
8
|
|
|
|
|
9
|
|
|
class InvoiceTest extends SapphireTest |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Add some scaffold order records |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected static $fixture_file = 'OrdersScaffold.yml'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Setup test only objects |
|
20
|
|
|
* |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
protected static $extra_dataobjects = [ |
|
24
|
|
|
TestProduct::class |
|
25
|
|
|
]; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Add some extra functionality on construction |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
public function setUp() |
|
33
|
|
|
{ |
|
34
|
|
|
parent::setUp(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Clean up after tear down |
|
39
|
|
|
* |
|
40
|
|
|
* @return void |
|
41
|
|
|
*/ |
|
42
|
|
|
public function tearDown() |
|
43
|
|
|
{ |
|
44
|
|
|
parent::tearDown(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Test that mark paid flags the order as paid |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testMarkPaid() |
|
53
|
|
|
{ |
|
54
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
55
|
|
|
$invoice->markPaid(); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals("paid", $invoice->Status); |
|
58
|
|
|
$this->assertTrue($invoice->isPaid()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testMarkPartPaid() |
|
62
|
|
|
{ |
|
63
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
64
|
|
|
$invoice->markPartPaid(); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertEquals("part-paid", $invoice->Status); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testMarkPending() |
|
70
|
|
|
{ |
|
71
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
72
|
|
|
$invoice->markPending(); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertEquals("pending", $invoice->Status); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function testMarkProcessing() |
|
78
|
|
|
{ |
|
79
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
80
|
|
|
$invoice->markProcessing(); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertEquals("processing", $invoice->Status); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function testMarkCanceled() |
|
86
|
|
|
{ |
|
87
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
88
|
|
|
$invoice->markCanceled(); |
|
89
|
|
|
|
|
90
|
|
|
$this->assertEquals("canceled", $invoice->Status); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function testMarkRefunded() |
|
94
|
|
|
{ |
|
95
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
96
|
|
|
$invoice->markRefunded(); |
|
97
|
|
|
|
|
98
|
|
|
$this->assertEquals("refunded", $invoice->Status); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function testMarkDispatched() |
|
102
|
|
|
{ |
|
103
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
104
|
|
|
$invoice->markDispatched(); |
|
105
|
|
|
|
|
106
|
|
|
$this->assertEquals("dispatched", $invoice->Status); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function testMarkCollected() |
|
110
|
|
|
{ |
|
111
|
|
|
$invoice = $this->objFromFixture(Invoice::class, 'unpaid'); |
|
112
|
|
|
$invoice->markCollected(); |
|
113
|
|
|
|
|
114
|
|
|
$this->assertEquals("collected", $invoice->Status); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|