1 | <?php |
||
10 | use SilverStripe\Dev\CSSContentParser; |
||
11 | use SilverStripe\Dev\SapphireTest; |
||
12 | use SilverStripe\Forms\FieldList; |
||
13 | use SilverStripe\Forms\Form; |
||
14 | use SilverStripe\Forms\GridField\GridField; |
||
15 | use SilverStripe\Forms\GridField\GridFieldConfig; |
||
16 | use SilverStripe\Omnipay\GatewayInfo; |
||
17 | use SilverStripe\Omnipay\Model\Payment; |
||
18 | use SilverStripe\ORM\ArrayList; |
||
19 | use SilverStripe\ORM\DataList; |
||
20 | |||
21 | /** |
||
22 | * Test payment actions in GridFields |
||
23 | */ |
||
24 | class GridFieldPaymentActionsTest extends SapphireTest |
||
25 | { |
||
26 | |||
27 | /** @var ArrayList */ |
||
28 | protected $list; |
||
29 | |||
30 | /** @var GridField */ |
||
31 | protected $gridField; |
||
32 | |||
33 | /** @var Form */ |
||
34 | protected $form; |
||
35 | |||
36 | /** @var string */ |
||
37 | protected static $fixture_file = 'GridFieldTestPayments.yml'; |
||
38 | |||
39 | public function setUp() |
||
59 | |||
60 | public function testButtons() |
||
61 | { |
||
62 | $content = new CSSContentParser($this->gridField->FieldHolder()); |
||
63 | |||
64 | // There should be a total of 5 items in the GridField (see fixture file) |
||
65 | $this->assertEquals(5, count($content->getBySelector('tr.ss-gridfield-item'))); |
||
66 | |||
67 | // Two of the payments should have capture buttons |
||
68 | $this->assertEquals(2, count($content->getBySelector('.gridfield-button-capture'))); |
||
69 | |||
70 | // Two payments should have a refund button |
||
71 | $this->assertEquals(2, count($content->getBySelector('.gridfield-button-refund'))); |
||
72 | |||
73 | // Two payments should have a void button |
||
74 | $this->assertEquals(2, count($content->getBySelector('.gridfield-button-void'))); |
||
75 | |||
76 | // Disallow actions for Manual Gateway |
||
77 | Config::modify()->merge(GatewayInfo::class, 'Manual', array( |
||
78 | 'can_capture' => false, |
||
79 | 'can_refund' => false, |
||
80 | 'can_void' => false |
||
81 | )); |
||
82 | |||
83 | $content = new CSSContentParser($this->gridField->FieldHolder()); |
||
84 | |||
85 | // Now only one payment should have a capture button |
||
86 | $this->assertEquals(1, count($content->getBySelector('.gridfield-button-capture'))); |
||
87 | |||
88 | // Now only one payment should have a refund button |
||
89 | $this->assertEquals(1, count($content->getBySelector('.gridfield-button-refund'))); |
||
90 | |||
91 | // Now only one payment should have a void button |
||
92 | $this->assertEquals(1, count($content->getBySelector('.gridfield-button-void'))); |
||
110 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..