Passed
Pull Request — master (#20)
by Jason
02:52
created

AddToCartFormTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetProductFields() 0 7 1
A testGetProductActions() 0 7 1
1
<?php
2
3
namespace Dynamic\Foxy\Test\Form;
4
5
use Dynamic\Foxy\Form\AddToCartForm;
6
use Dynamic\Foxy\Test\TestOnly\TestShippableProduct;
7
use Dynamic\Foxy\Test\TestOnly\TestShippableProductController;
8
use SilverStripe\Core\Injector\Injector;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\Forms\FieldList;
11
12
class AddToCartFormTest extends SapphireTest
13
{
14
    protected static $fixture_file = '../fixtures.yml';
15
16
    public function testGetProductFields()
17
    {
18
        $object = Injector::inst()->create(TestShippableProduct::class);
19
        $controller = TestShippableProductController::create($object);
20
        $form = $controller->AddToCartForm($controller, __FUNCTION__, null, null, null, $object);
21
        $fields = $form->Fields();
22
        $this->assertInstanceOf(FieldList::class, $fields);
23
    }
24
25
    public function testGetProductActions()
26
    {
27
        $object = Injector::inst()->create(TestShippableProduct::class);
28
        $controller = TestShippableProductController::create($object);
29
        $form = $controller->AddToCartForm($controller, __FUNCTION__, null, null, null, $object);
30
        $fields = $form->Actions();
31
        $this->assertInstanceOf(FieldList::class, $fields);
32
    }
33
}
34