mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Update namespacing and include paths in new multiple option field tests
This commit is contained in:
parent
91bac6dcf4
commit
12aad64972
@ -26,7 +26,8 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField
|
|||||||
public function getFormField()
|
public function getFormField()
|
||||||
{
|
{
|
||||||
$field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
$field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
||||||
->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder');
|
->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder')
|
||||||
|
->setTemplate(UserFormsCheckboxSetField::class);
|
||||||
|
|
||||||
// Set the default checked items
|
// Set the default checked items
|
||||||
$defaultCheckedItems = $this->getDefaultOptions();
|
$defaultCheckedItems = $this->getDefaultOptions();
|
||||||
|
@ -26,6 +26,7 @@ use SilverStripe\Forms\TextareaField;
|
|||||||
use SilverStripe\Forms\TextField;
|
use SilverStripe\Forms\TextField;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
use SilverStripe\UserForms\Model\EditableFormField\EditableEmailField;
|
use SilverStripe\UserForms\Model\EditableFormField\EditableEmailField;
|
||||||
use SilverStripe\UserForms\Model\EditableFormField;
|
use SilverStripe\UserForms\Model\EditableFormField;
|
||||||
use SilverStripe\UserForms\Model\EditableFormField\EditableMultipleOptionField;
|
use SilverStripe\UserForms\Model\EditableFormField\EditableMultipleOptionField;
|
||||||
@ -504,7 +505,7 @@ class EmailRecipient extends DataObject
|
|||||||
public function getEmailBodyContent()
|
public function getEmailBodyContent()
|
||||||
{
|
{
|
||||||
if ($this->SendPlain) {
|
if ($this->SendPlain) {
|
||||||
return DBField::create_field('HTMLText', $this->EmailBody)->NoHTML();
|
return DBField::create_field('HTMLText', $this->EmailBody)->Plain();
|
||||||
}
|
}
|
||||||
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
|
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
<% if $Legend %>
|
<% if $Legend %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>$Legend</legend>
|
<legend>$Legend</legend>
|
||||||
<% include UserFormFields %>
|
<% include SilverStripe\\UserForms\\Form\\UserFormFields %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="userform-fields">
|
<div class="userform-fields">
|
||||||
<% include UserFormFields %>
|
<% include SilverStripe\\UserForms\\Form\\UserFormFields %>
|
||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class EditableCheckboxGroupFieldTest extends SapphireTest
|
|
||||||
{
|
|
||||||
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that this element is rendered with a custom template
|
|
||||||
*/
|
|
||||||
public function testRenderedWithCustomTemplate()
|
|
||||||
{
|
|
||||||
$checkboxGroup = $this->objFromFixture('EditableCheckboxGroupField', 'checkbox-group');
|
|
||||||
$this->assertEquals('UserFormsCheckboxSetField', $checkboxGroup->getFormField()->getTemplate());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class EditableRadioFieldTest extends SapphireTest
|
|
||||||
{
|
|
||||||
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that this element is rendered with a custom template
|
|
||||||
*/
|
|
||||||
public function testRenderedWithCustomTemplate()
|
|
||||||
{
|
|
||||||
$radio = $this->objFromFixture('EditableRadioField', 'radio-field');
|
|
||||||
$this->assertEquals('UserFormsOptionSetField', $radio->getFormField()->getTemplate());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\UserForms\FormField\UserFormsCheckboxSetField;
|
||||||
|
use SilverStripe\UserForms\Model\EditableFormField\EditableCheckboxGroupField;
|
||||||
|
|
||||||
|
class EditableCheckboxGroupFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
protected static $fixture_file = '../EditableFormFieldTest.yml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that this element is rendered with a custom template
|
||||||
|
*/
|
||||||
|
public function testRenderedWithCustomTemplate()
|
||||||
|
{
|
||||||
|
$checkboxGroup = $this->objFromFixture(EditableCheckboxGroupField::class, 'checkbox-group');
|
||||||
|
$this->assertSame(UserFormsCheckboxSetField::class, $checkboxGroup->getFormField()->getTemplate());
|
||||||
|
}
|
||||||
|
}
|
25
tests/Model/EditableFormField/EditableRadioFieldTest.php
Normal file
25
tests/Model/EditableFormField/EditableRadioFieldTest.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\UserForms\FormField\UserFormsCheckboxSetField;
|
||||||
|
use SilverStripe\UserForms\Model\EditableFormField\EditableCheckboxGroupField;
|
||||||
|
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
|
||||||
|
|
||||||
|
class EditableRadioFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
protected static $fixture_file = '../EditableFormFieldTest.yml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that this element is rendered with a custom template
|
||||||
|
*/
|
||||||
|
public function testRenderedWithCustomTemplate()
|
||||||
|
{
|
||||||
|
$radio = $this->objFromFixture(EditableRadioField::class, 'radio-field');
|
||||||
|
$this->assertSame(
|
||||||
|
'SilverStripe\\UserForms\\FormField\\UserFormsOptionSetField',
|
||||||
|
$radio->getFormField()->getTemplate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
|
||||||
|
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\Forms\DropdownField;
|
||||||
|
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
||||||
|
|
||||||
class EditableTextFieldTest extends SapphireTest
|
class EditableTextFieldTest extends SapphireTest
|
||||||
{
|
{
|
||||||
public function testGetCmsFields()
|
public function testGetCmsFields()
|
||||||
{
|
{
|
||||||
Config::inst()->remove('EditableTextField', 'autocomplete_options');
|
Config::modify()->set(EditableTextField::class, 'autocomplete_options', ['foo' => 'foo']);
|
||||||
Config::inst()->update('EditableTextField', 'autocomplete_options', array('foo' => 'foo'));
|
|
||||||
|
|
||||||
$field = new EditableTextField;
|
$field = new EditableTextField;
|
||||||
$result = $field->getCMSFields();
|
$result = $field->getCMSFields();
|
||||||
|
|
||||||
$autocompleteField = $result->fieldByName('Root.Main.Autocomplete');
|
$autocompleteField = $result->fieldByName('Root.Main.Autocomplete');
|
||||||
$this->assertInstanceOf('DropdownField', $autocompleteField);
|
$this->assertInstanceOf(DropdownField::class, $autocompleteField);
|
||||||
$this->assertEquals(array('foo' => 'foo'), $autocompleteField->getSource());
|
$this->assertEquals(['foo' => 'foo'], $autocompleteField->getSource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class UserDefinedForm_EmailRecipientTest extends SapphireTest
|
namespace SilverStripe\UserForms\Tests\Model\Recipient;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\UserForms\Model\Recipient\EmailRecipient;
|
||||||
|
|
||||||
|
class EmailRecipientTest extends SapphireTest
|
||||||
{
|
{
|
||||||
protected static $fixture_file = 'UserDefinedForm_EmailRecipientTest.yml';
|
protected static $fixture_file = 'EmailRecipientTest.yml';
|
||||||
|
|
||||||
public function testShortcodesAreRenderedInEmailPreviewContent()
|
public function testShortcodesAreRenderedInEmailPreviewContent()
|
||||||
{
|
{
|
||||||
$page = $this->objFromFixture('SiteTree', 'about_us');
|
$page = $this->objFromFixture(SiteTree::class, 'about_us');
|
||||||
|
|
||||||
$recipient = UserDefinedForm_EmailRecipient::create();
|
$recipient = EmailRecipient::create();
|
||||||
$recipient->SendPlain = false;
|
$recipient->SendPlain = false;
|
||||||
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
about_us:
|
about_us:
|
||||||
Title: About Us
|
Title: About Us
|
||||||
URLSegment: about-us
|
URLSegment: about-us
|
Loading…
Reference in New Issue
Block a user