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
|
|
|
|