1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Test the Payable extension |
5
|
|
|
*/ |
6
|
|
|
class PayableUITest extends SapphireTest |
7
|
|
|
{ |
8
|
|
|
protected $extraDataObjects = array('PayableUITest_Order'); |
9
|
|
|
|
10
|
|
|
public function setUpOnce() |
11
|
|
|
{ |
12
|
|
|
Payment::add_extension('PayableUITest_PaymentExtension'); |
13
|
|
|
|
14
|
|
|
parent::setUpOnce(); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function tearDownOnce() |
18
|
|
|
{ |
19
|
|
|
parent::tearDownOnce(); |
20
|
|
|
|
21
|
|
|
Payment::remove_extension('PayableUITest_PaymentExtension'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Test the CMS fields added via extension |
26
|
|
|
*/ |
27
|
|
|
public function testCMSFields() |
28
|
|
|
{ |
29
|
|
|
// Add the payable UI extension to the Test_Order (which us part of the tests from the omnopay module) |
30
|
|
|
$order = new PayableUITest_Order(); |
31
|
|
|
$fields = $order->getCMSFields(); |
32
|
|
|
|
33
|
|
|
$this->assertTrue($fields->hasTabSet()); |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** @var GridField $gridField */ |
36
|
|
|
$gridField = $fields->fieldByName('Root.Payments.Payments'); |
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf('GridField', $gridField); |
|
|
|
|
39
|
|
|
|
40
|
|
|
// Check the actions/buttons that should be in place |
41
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType('GridFieldEditButton')); |
|
|
|
|
42
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
|
|
|
|
43
|
|
|
'SilverStripe\Omnipay\UI\GridField\GridFieldCaptureAction' |
44
|
|
|
)); |
45
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
|
|
|
|
46
|
|
|
'SilverStripe\Omnipay\UI\GridField\GridFieldRefundAction' |
47
|
|
|
)); |
48
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
|
|
|
|
49
|
|
|
'SilverStripe\Omnipay\UI\GridField\GridFieldVoidAction' |
50
|
|
|
)); |
51
|
|
|
|
52
|
|
|
// check the actions buttons that should be removed |
53
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType('GridFieldAddNewButton')); |
|
|
|
|
54
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType('GridFieldDeleteAction')); |
|
|
|
|
55
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType('GridFieldFilterHeader')); |
|
|
|
|
56
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType('GridFieldPageCount')); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
class PayableUITest_Order extends DataObject implements TestOnly |
62
|
|
|
{ |
63
|
|
|
private static $extensions = array( |
|
|
|
|
64
|
|
|
'Payable', |
65
|
|
|
'PayableUIExtension' |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
class PayableUITest_PaymentExtension extends DataExtension implements TestOnly |
70
|
|
|
{ |
71
|
|
|
private static $has_one = array( |
72
|
|
|
'PayableUITest_Order' => 'PayableUITest_Order' |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.