Passed
Push — master ( 07507d...4e9ab4 )
by Matthew
02:33
created

LocatorFormTest::testFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Dynamic\Locator\Tests;
4
5
use Dynamic\Locator\Locator;
6
use Dynamic\Locator\LocatorController;
7
use Dynamic\Locator\LocatorForm;
8
use SilverStripe\Dev\FunctionalTest;
9
use SilverStripe\Forms\FieldList;
10
use SilverStripe\Forms\RequiredFields;
11
12
class LocatorFormTest extends FunctionalTest
13
{
14
    /**
15
     * @var string
16
     */
17
    protected static $fixture_file = '../fixtures.yml';
18
19
    /**
20
     *
21
     */
22
    public function testLocatorFormBase()
23
    {
24
        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
25
26
        $this->assertInstanceOf(FieldList::class, $form->Fields());
27
        $this->assertInstanceOf(RequiredFields::class, $form->getValidator());
28
    }
29
30
    /**
31
     *
32
     */
33
    public function testUpdateRequiredFields()
34
    {
35
        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
36
        $validator = $form->getValidator();
37
38
        $validator->removeRequiredField('Address');
39
        $validator->addRequiredField('Foo');
40
41
        $this->assertEquals(['Foo'], $form->getValidator()->getRequired());
42
    }
43
44
45
    public function testFields()
46
    {
47
        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
48
        $this->assertInstanceOf(FieldList::class, $form->Fields());
49
    }
50
51
52
    public function testActions()
53
    {
54
        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
55
        $this->assertInstanceOf(FieldList::class, $form->Actions());
56
    }
57
}
58