-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from muskie9/enhancement/requiredFields#144
ENHANCEMENT LocatorForm required fields
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<phpunit bootstrap="../framework/tests/bootstrap.php" colors="true"> | ||
|
||
<testsuite name="Default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
|
||
<listeners> | ||
<listener class="SS_TestListener" file="../framework/dev/TestListener.php"/> | ||
</listeners> | ||
|
||
<groups> | ||
<exclude> | ||
<group>sanitychecks</group> | ||
</exclude> | ||
</groups> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">code</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
class LocatorFormTest extends FunctionalTest | ||
{ | ||
|
||
public function testLocatorFormBase() | ||
{ | ||
$form = LocatorForm::create(Locator_Controller::create(Locator::get()->first()), 'LocatorForm'); | ||
|
||
$this->assertInstanceOf('FieldList', $form->Fields()); | ||
$this->assertInstanceOf('RequiredFields', $form->getValidator()); | ||
} | ||
|
||
public function testUpdateRequiredFields() | ||
{ | ||
$form = LocatorFormExtendedForm::create(Locator_Controller::create(Locator::get()->first()), 'LocatorForm'); | ||
|
||
$this->assertEquals(['Foo'], $form->getValidator()->getRequired()); | ||
} | ||
|
||
} | ||
|
||
class LocatorFormTestFormExtension extends Extension implements TestOnly | ||
{ | ||
public function updateRequiredFields(RequiredFields $validator) | ||
{ | ||
$validator->removeRequiredField('Address'); | ||
$validator->addRequiredField('Foo'); | ||
} | ||
} | ||
|
||
class LocatorFormExtendedForm extends LocatorForm implements TestOnly | ||
{ | ||
|
||
private static $extensions = [ | ||
'LocatorFormTestFormExtension', | ||
]; | ||
|
||
} |