Completed
Push — master ( 1c035c...47b80b )
by Roman
03:58
created

PayableUITest::testCMSFields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 31
rs 8.8571
cc 1
eloc 17
nc 1
nop 0
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());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PayableUITest>.

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.

Loading history...
34
35
        /** @var GridField $gridField */
36
        $gridField = $fields->fieldByName('Root.Payments.Payments');
37
38
        $this->assertInstanceOf('GridField', $gridField);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<PayableUITest>.

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.

Loading history...
39
40
        // Check the actions/buttons that should be in place
41
        $this->assertNotNull($gridField->getConfig()->getComponentByType('GridFieldEditButton'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
42
        $this->assertNotNull($gridField->getConfig()->getComponentByType(
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
43
            'SilverStripe\Omnipay\UI\GridField\GridFieldCaptureAction'
44
        ));
45
        $this->assertNotNull($gridField->getConfig()->getComponentByType(
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
46
            'SilverStripe\Omnipay\UI\GridField\GridFieldRefundAction'
47
        ));
48
        $this->assertNotNull($gridField->getConfig()->getComponentByType(
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
49
            'SilverStripe\Omnipay\UI\GridField\GridFieldVoidAction'
50
        ));
51
52
        // check the actions buttons that should be removed
53
        $this->assertNull($gridField->getConfig()->getComponentByType('GridFieldAddNewButton'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
54
        $this->assertNull($gridField->getConfig()->getComponentByType('GridFieldDeleteAction'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
55
        $this->assertNull($gridField->getConfig()->getComponentByType('GridFieldFilterHeader'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
56
        $this->assertNull($gridField->getConfig()->getComponentByType('GridFieldPageCount'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<PayableUITest>.

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.

Loading history...
57
    }
58
59
}
60
61
class PayableUITest_Order extends DataObject implements TestOnly
62
{
63
    private static $extensions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
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