Passed
Pull Request — master (#7)
by Jason
02:16
created

testUpdateProductActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Dynamic\Foxy\Inventory\Test\Extension;
4
5
use Dynamic\Foxy\Form\AddToCartForm;
6
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProduct;
7
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProductController;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\Forms\FieldList;
10
11
class AddToCartFormExtensionTest extends SapphireTest
12
{
13
    /**
14
     * @var string
15
     */
16
    protected static $fixture_file = '../fixtures.yml';
17
18
    /**
19
     * @var array
20
     */
21
    protected static $extra_dataobjects = [
22
        TestProduct::class,
23
    ];
24
25
    /**
26
     * @var array
27
     */
28
    protected static $extra_controllers = [
29
        TestProductController::class,
30
    ];
31
32
    /**
33
     *
34
     */
35
    public function testUpdateProductFields()
36
    {
37
        $object = $this->objFromFixture(TestProduct::class, 'one');
38
        $controller = TestProductController::create($object);
39
        $form = $controller->AddToCartForm();
40
        $fields = $form->Fields();
41
        $this->assertInstanceOf(FieldList::class, $fields);
42
        $this->assertNotNull($fields->dataFieldByName('expires'));
43
44
        // todo: add assertions to cover isOutOfStock() check via fixtures
45
    }
46
47
    /**
48
     *
49
     */
50
    public function testUpdateProductActions()
51
    {
52
        $object = $this->objFromFixture(TestProduct::class, 'one');
53
        $controller = TestProductController::create($object);
54
        $form = $controller->AddToCartForm();
55
        $fields = $form->Actions();
56
        $this->assertInstanceOf(FieldList::class, $fields);
57
58
        // todo: add assertions to cover isOutOfStock() check via fixtures
59
    }
60
61
    /**
62
     *
63
     */
64
    public function testIsOutOfStock()
65
    {
66
        $this->markTestSkipped();
67
        // todo: write test to test out of stock via fixtures
68
    }
69
}
70