1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bummzack\SsOmnipayUI\Tests; |
4
|
|
|
|
5
|
|
|
use Bummzack\SsOmnipayUI\GridField\GridFieldCaptureAction; |
6
|
|
|
use Bummzack\SsOmnipayUI\GridField\GridFieldRefundAction; |
7
|
|
|
use Bummzack\SsOmnipayUI\GridField\GridFieldVoidAction; |
8
|
|
|
use SilverStripe\Core\Config\Config; |
9
|
|
|
use SilverStripe\Dev\SapphireTest; |
10
|
|
|
use SilverStripe\Forms\GridField\GridField; |
11
|
|
|
use SilverStripe\Forms\GridField\GridFieldAddNewButton; |
12
|
|
|
use SilverStripe\Forms\GridField\GridFieldDeleteAction; |
13
|
|
|
use SilverStripe\Forms\GridField\GridFieldEditButton; |
14
|
|
|
use SilverStripe\Forms\GridField\GridFieldFilterHeader; |
15
|
|
|
use SilverStripe\Forms\GridField\GridFieldPageCount; |
16
|
|
|
use SilverStripe\Omnipay\Model\Payment; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Test the Payable extension |
20
|
|
|
*/ |
21
|
|
|
class PayableUITest extends SapphireTest |
22
|
|
|
{ |
23
|
|
|
protected $extraDataObjects = [PayableUITestOrder::class]; |
24
|
|
|
|
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
Config::modify()->set(Payment::class, 'extensions', PayableUITestPaymentExtension::class); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Test the CMS fields added via extension |
33
|
|
|
*/ |
34
|
|
|
public function testCMSFields() |
35
|
|
|
{ |
36
|
|
|
// Add the payable UI extension to the Test_Order (which us part of the tests from the omnipay module) |
37
|
|
|
$order = new PayableUITestOrder(); |
38
|
|
|
$fields = $order->getCMSFields(); |
39
|
|
|
|
40
|
|
|
$this->assertTrue($fields->hasTabSet()); |
41
|
|
|
|
42
|
|
|
/** @var GridField $gridField */ |
43
|
|
|
$gridField = $fields->fieldByName('Root.Payments.Payments'); |
44
|
|
|
|
45
|
|
|
$this->assertInstanceOf(GridField::class, $gridField); |
46
|
|
|
|
47
|
|
|
// Check the actions/buttons that should be in place |
48
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType(GridFieldEditButton::class)); |
49
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
50
|
|
|
GridFieldCaptureAction::class |
51
|
|
|
)); |
52
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
53
|
|
|
GridFieldRefundAction::class |
54
|
|
|
)); |
55
|
|
|
$this->assertNotNull($gridField->getConfig()->getComponentByType( |
56
|
|
|
GridFieldVoidAction::class |
57
|
|
|
)); |
58
|
|
|
|
59
|
|
|
// check the actions buttons that should be removed |
60
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType(GridFieldAddNewButton::class)); |
61
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType(GridFieldDeleteAction::class)); |
62
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType(GridFieldFilterHeader::class)); |
63
|
|
|
$this->assertNull($gridField->getConfig()->getComponentByType(GridFieldPageCount::class)); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|