Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Make validator param nullable #11512

Merged

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Dec 16, 2024

Issue silverstripe/.github#349

Two commits

API commit Fixes

  1. SilverStripe\Forms\Tests\GridField\GridFieldTest::testValidationMessageInOutput
    TypeError: SilverStripe\Forms\Form::setValidator(): Argument 1 ($validator) must be of type SilverStripe\Forms\Validation\Validator, null given, called in /home/runner/work/silverstripe-installer/silverstripe-installer/vendor/silverstripe/framework/tests/php/Forms/GridField/GridFieldTest.php on line 554

MNT commit fixes

  1. SilverStripe\Forms\Tests\DropdownFieldTest::testGetDefaultValue
    The data provider specified for SilverStripe\Forms\Tests\DropdownFieldTest::testGetDefaultValue is invalid
    Data Provider method SilverStripe\Forms\Tests\DropdownFieldTest::provideGetDefaultValue() is not static

and

  1. SilverStripe\Forms\Tests\TreeDropdownFieldTest::testTreeSearchUsingSubObject
    is found, nested under
    Failed asserting that 'Child B of Four SubObject' matches expected null.

@emteknetnz emteknetnz marked this pull request as ready for review December 16, 2024 00:21
@emteknetnz emteknetnz force-pushed the pulls/6.0/broken-builds branch from 8cce5b7 to bfe6f94 Compare December 16, 2024 03:46
@@ -303,9 +303,9 @@ public function testTreeSearchUsingSubObject()
$cssPath = 'ul.tree li#selector-TestTree-' . $subObject1->ID . ' li#selector-TestTree-' . $subObject1ChildB->ID . ' a';
$firstResult = $parser->getBySelector($cssPath);
$this->assertEquals(
$subObject1ChildB->Name,
$subObject1ChildB->Title,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test used to pass by accident. The fixtures in TreeDropdownFieldTest.yml have a Title property, not a Name property

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting to know what we changed that stopped that from working, but you're right that it shouldn't have been.

* @return $this
*/
public function setValidator(Validator $validator)
public function setValidator(?Validator $validator)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to have this param nullable, as there is no default and you should be able to 'unset' any existing validators, as there is no longer a need to always have a validator now that the Form will loop form fields and call validate() on them

@GuySartorelli GuySartorelli merged commit a393ce7 into silverstripe:6.0 Dec 16, 2024
12 checks passed
@GuySartorelli GuySartorelli deleted the pulls/6.0/broken-builds branch December 16, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants