Completed
Pull Request — master (#19)
by Robbie
01:56
created

DMSDocumentCartExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testMaximumCartQuantity() 0 16 1
A testCmsFieldsHaveRequiredCssClasses() 0 12 1
A testGetValidationResult() 0 6 1
1
<?php
2
3
class DMSDocumentCartExtensionTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    protected $requiredExtensions = array(
6
        'DMSDocument' => array('DMSDocumentCartExtension')
7
    );
8
9
    public function testMaximumCartQuantity()
10
    {
11
        $document = DMSDocument::create(array('AllowedInCart' => true, 'MaximumCartQuantity' => ''));
12
13
        $this->assertFalse($document->getHasQuantityLimit());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
14
15
        $document->MaximumCartQuantity = 0;
16
        $this->assertFalse($document->getHasQuantityLimit());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
17
18
        $document->MaximumCartQuantity = 1;
19
        $this->assertTrue($document->getHasQuantityLimit());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
20
        $this->assertSame(1, $document->getMaximumQuantity());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
21
22
        $document->MaximumCartQuantity = 10;
23
        $this->assertSame(10, $document->getMaximumQuantity());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
24
    }
25
26
    /**
27
     * The CSS classes are required for the CMS Javascript to work, assert that they are correct
28
     */
29
    public function testCmsFieldsHaveRequiredCssClasses()
30
    {
31
        $fields = DMSDocument::create()->getCMSFields();
32
33
        $allowedInCart = $fields->fieldByName('AllowedInCart');
34
        $this->assertInstanceOf('CheckboxField', $allowedInCart);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
35
        $this->assertTrue((bool) $allowedInCart->hasClass('dms-allowed-in-cart'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
36
37
        $allowedInCart = $fields->fieldByName('MaximumCartQuantity');
38
        $this->assertInstanceOf('TextField', $allowedInCart);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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
        $this->assertTrue((bool) $allowedInCart->hasClass('dms-maximum-cart-quantity'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
40
    }
41
42
    /**
43
     * Ensure that validation messages can be retrieved once, cleared, then not again
44
     */
45
    public function testGetValidationResult()
46
    {
47
        Session::set('dms-cart-validation-message', 'testing');
48
        $this->assertSame('testing', DMSDocument::create()->getValidationResult());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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
        $this->assertFalse(DMSDocument::create()->getValidationResult());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DMSDocumentCartExtensionTest>.

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...
50
    }
51
}
52