diff --git a/tests/php/Model/SubClassFormTest.php b/tests/php/Model/SubClassFormTest.php new file mode 100644 index 0000000..3007310 --- /dev/null +++ b/tests/php/Model/SubClassFormTest.php @@ -0,0 +1,53 @@ + [UserFormFieldEditorExtension::class], + ]; + + protected static $extra_dataobjects = [ + SubClassForm::class, + ]; + + protected function setUp(): void + { + parent::setUp(); + Email::config()->update('admin_email', 'no-reply@example.com'); + } + + public function testGetCMSFieldsShowInSummary() + { + $this->logInWithPermission('ADMIN'); + $form = $this->objFromFixture(SubClassForm::class, 'summary-rules-form'); + + $fields = $form->getCMSFields(); + + $this->assertInstanceOf(GridField::class, $fields->dataFieldByName('Submissions')); + + $submissionsgrid = $fields->dataFieldByName('Submissions'); + $gridFieldDataColumns = $submissionsgrid->getConfig()->getComponentByType(GridFieldDataColumns::class); + + $summaryFields = $gridFieldDataColumns->getDisplayFields($submissionsgrid); + + $this->assertContains('SummaryShow', array_keys($summaryFields ?? []), 'Summary field not showing displayed field'); + $this->assertNotContains('SummaryHide', array_keys($summaryFields ?? []), 'Summary field showing displayed field'); + } +} diff --git a/tests/php/Model/SubClassFormTest.yml b/tests/php/Model/SubClassFormTest.yml new file mode 100644 index 0000000..3cfbd9e --- /dev/null +++ b/tests/php/Model/SubClassFormTest.yml @@ -0,0 +1,17 @@ +SilverStripe\UserForms\Model\EditableFormField\EditableTextField: + summary-show: + Name: SummaryShow + Title: Summary Text Field + ShowInSummary: true + + summary-hide: + Name: SummaryHide + Title: Summary Text Field + ShowInSummary: false + +SilverStripe\UserForms\Tests\Model\SubClassFormTest\SubClassForm: + summary-rules-form: + Title: Summary Fields Form + Fields: + - =>SilverStripe\UserForms\Model\EditableFormField\EditableTextField.summary-show + - =>SilverStripe\UserForms\Model\EditableFormField\EditableTextField.summary-hide diff --git a/tests/php/Model/SubClassFormTest/SubClassForm.php b/tests/php/Model/SubClassFormTest/SubClassForm.php new file mode 100644 index 0000000..6c9034c --- /dev/null +++ b/tests/php/Model/SubClassFormTest/SubClassForm.php @@ -0,0 +1,11 @@ +