Passed
Pull Request — master (#7)
by Jason
02:09
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
43
        // todo: add assertions to cover CartExpiration and isOutOfStock() checks via fixtures
44
    }
45
46
    /**
47
     *
48
     */
49
    public function testUpdateProductActions()
50
    {
51
        $object = $this->objFromFixture(TestProduct::class, 'one');
52
        $controller = TestProductController::create($object);
53
        $form = $controller->AddToCartForm();
54
        $fields = $form->Actions();
55
        $this->assertInstanceOf(FieldList::class, $fields);
56
57
        // todo: add assertions to cover isOutOfStock() check via fixtures
58
    }
59
60
    /**
61
     *
62
     */
63
    public function testIsOutOfStock()
64
    {
65
        $this->markTestSkipped();
66
        // todo: write test to test out of stock via fixtures
67
    }
68
}
69