1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverShop\Tests\Page; |
4
|
|
|
|
5
|
|
|
use SilverShop\Extension\OrderManipulationExtension; |
6
|
|
|
use SilverShop\Model\Order; |
7
|
|
|
use SilverShop\Page\CheckoutPage; |
8
|
|
|
use SilverShop\Tests\ShopTest; |
9
|
|
|
use SilverStripe\Control\Director; |
10
|
|
|
use SilverStripe\Dev\FunctionalTest; |
11
|
|
|
|
12
|
|
|
class CheckoutPageTest extends FunctionalTest |
13
|
|
|
{ |
14
|
|
|
protected static $fixture_file = [ |
15
|
|
|
__DIR__ . '/../Fixtures/Pages.yml', |
16
|
|
|
__DIR__ . '/../Fixtures/shop.yml', |
17
|
|
|
]; |
18
|
|
|
protected static $disable_theme = true; |
19
|
|
|
protected static $use_draft_site = true; |
20
|
|
|
protected $controller; |
21
|
|
|
|
22
|
|
|
public function setUp(): void |
23
|
|
|
{ |
24
|
|
|
parent::setUp(); |
25
|
|
|
ShopTest::setConfiguration(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testActionsForm() |
29
|
|
|
{ |
30
|
|
|
$order = $this->objFromFixture(Order::class, "unpaid"); |
31
|
|
|
OrderManipulationExtension::add_session_order($order); |
32
|
|
|
$this->get("/checkout/order/" . $order->ID); |
33
|
|
|
|
34
|
|
|
//make payment action |
35
|
|
|
$this->post( |
36
|
|
|
"/checkout/order/ActionsForm", |
37
|
|
|
[ |
38
|
|
|
'OrderID' => $order->ID, |
39
|
|
|
'PaymentMethod' => 'Dummy', |
40
|
|
|
'action_dopayment' => 'submit', |
41
|
|
|
] |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
//cancel action |
45
|
|
|
$this->post( |
46
|
|
|
"/checkout/order/ActionsForm", |
47
|
|
|
[ |
48
|
|
|
'OrderID' => $order->ID, |
49
|
|
|
'action_docancel' => 'submit', |
50
|
|
|
] |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
$this->markTestIncomplete('Add some assertions'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testCanViewCheckoutPage() |
57
|
|
|
{ |
58
|
|
|
$this->get('checkout'); |
59
|
|
|
$this->markTestIncomplete("check order hasn't started"); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testFindLink() |
63
|
|
|
{ |
64
|
|
|
$checkoutpage = $this->objFromFixture(CheckoutPage::class, 'checkout'); |
65
|
|
|
$checkoutpage->publishSingle(); |
66
|
|
|
$link = CheckoutPage::find_link(); |
67
|
|
|
$this->assertEquals( |
68
|
|
|
Director::baseURL() . 'checkout/', |
69
|
|
|
$link, |
70
|
|
|
'find_link() returns the correct link to checkout.' |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|