Passed
Pull Request — master (#7)
by Jason
01:54
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\Form\TestAddToCartForm;
7
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProduct;
8
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProductController;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\Forms\FieldList;
11
12
class AddToCartFormExtensionTest extends SapphireTest
13
{
14
    /**
15
     * @var string
16
     */
17
    protected static $fixture_file = '../fixtures.yml';
18
19
    /**
20
     * @var array
21
     */
22
    protected static $extra_dataobjects = [
23
        TestProduct::class,
24
        TestAddToCartForm::class,
25
    ];
26
27
    /**
28
     * @var array
29
     */
30
    protected static $extra_controllers = [
31
        TestProductController::class,
32
    ];
33
34
    /**
35
     *
36
     */
37
    public function testUpdateProductFields()
38
    {
39
        $object = $this->objFromFixture(TestProduct::class, 'one');
40
        $controller = TestProductController::create($object);
41
        AddToCartForm::create($this->owner, __FUNCTION__, null, null, null, $controller->data());
0 ignored issues
show
Bug Best Practice introduced by
The property owner does not exist on Dynamic\Foxy\Inventory\T...ToCartFormExtensionTest. Did you maybe forget to declare it?
Loading history...
42
        $fields = $form->Fields();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $form seems to be never defined.
Loading history...
43
        $this->assertInstanceOf(FieldList::class, $fields);
44
        $this->assertNotNull($fields->dataFieldByName('expires'));
45
46
        // todo: add assertions to cover isOutOfStock() check via fixtures
47
    }
48
49
    /**
50
     *
51
     */
52
    public function testUpdateProductActions()
53
    {
54
        $object = $this->objFromFixture(TestProduct::class, 'one');
55
        $controller = TestProductController::create($object);
56
        $form = $controller->AddToCartForm();
57
        $fields = $form->Actions();
58
        $this->assertInstanceOf(FieldList::class, $fields);
59
60
        // todo: add assertions to cover isOutOfStock() check via fixtures
61
    }
62
63
    /**
64
     *
65
     */
66
    public function testIsOutOfStock()
67
    {
68
        $this->markTestSkipped();
69
        // todo: write test to test out of stock via fixtures
70
    }
71
}
72