mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #1177 from creative-commoners/pulls/5/stop-using-depr
API Stop using deprecated API
This commit is contained in:
commit
bf1a8cb3b2
@ -56,7 +56,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
||||
{
|
||||
$fieldEditor = $this->getFieldEditorGrid();
|
||||
|
||||
$fields->insertAfter(new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')), 'Main');
|
||||
$fields->insertAfter('Main', new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')));
|
||||
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
|
||||
|
||||
return $fields;
|
||||
@ -192,7 +192,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
||||
foreach ($this->owner->Fields() as $field) {
|
||||
// store any IDs of fields we publish so we don't unpublish them
|
||||
$seenIDs[] = $field->ID;
|
||||
$field->doPublish(Versioned::DRAFT, Versioned::LIVE);
|
||||
$field->publishRecursive();
|
||||
$field->destroy();
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
||||
public function onAfterRevertToLive()
|
||||
{
|
||||
foreach ($this->owner->Fields() as $field) {
|
||||
$field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT, false);
|
||||
$field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT);
|
||||
$field->writeWithoutVersion();
|
||||
}
|
||||
}
|
||||
|
@ -265,8 +265,8 @@ class EditableFileField extends EditableFormField
|
||||
*/
|
||||
public static function get_php_max_file_size()
|
||||
{
|
||||
$maxUpload = File::ini2bytes(ini_get('upload_max_filesize'));
|
||||
$maxPost = File::ini2bytes(ini_get('post_max_size'));
|
||||
$maxUpload = Convert::memstring2bytes(ini_get('upload_max_filesize'));
|
||||
$maxPost = Convert::memstring2bytes(ini_get('post_max_size'));
|
||||
return min($maxUpload, $maxPost);
|
||||
}
|
||||
|
||||
|
@ -116,16 +116,13 @@ class EditableMultipleOptionField extends EditableFormField
|
||||
* Duplicate a pages content. We need to make sure all the fields attached
|
||||
* to that page go with it
|
||||
*
|
||||
* @param bool $doWrite @deprecated
|
||||
* @param string $manyMany @deprecated
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function duplicate($doWrite = true, $manyMany = 'many_many')
|
||||
{
|
||||
// Versioned 1.0 has a bug where [] will result in _all_ relations being duplicated
|
||||
if ($manyMany === 'many_many' && !$this->manyMany()) {
|
||||
$manyMany = null;
|
||||
}
|
||||
|
||||
$clonedNode = parent::duplicate(true, $manyMany);
|
||||
$clonedNode = parent::duplicate(true);
|
||||
|
||||
foreach ($this->Options() as $field) {
|
||||
/** @var EditableOption $newField */
|
||||
|
@ -332,12 +332,12 @@ class EmailRecipient extends DataObject
|
||||
|
||||
if ($templates) {
|
||||
$fields->insertBefore(
|
||||
'EmailBodyHtml',
|
||||
DropdownField::create(
|
||||
'EmailTemplate',
|
||||
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template'),
|
||||
$templates
|
||||
)->addExtraClass('toggle-html-only'),
|
||||
'EmailBodyHtml'
|
||||
)->addExtraClass('toggle-html-only')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<nav aria-label="Pages in this form">
|
||||
<ul class="step-buttons">
|
||||
<% loop $Steps %>
|
||||
<li class="step-button-wrapper<% if $First %> current<% end_if %>" data-for="$Name">
|
||||
<li class="step-button-wrapper<% if $IsFirst %> current<% end_if %>" data-for="$Name">
|
||||
<%-- Remove js-align class to remove javascript positioning --%>
|
||||
<button class="step-button-jump js-align" disabled="disabled" data-step="$Pos"><% if $Top.ButtonText %>$Top.ButtonText <% end_if %>$Pos</button>
|
||||
</li>
|
||||
|
@ -24,7 +24,7 @@ class EditableNumericFieldTest extends SapphireTest
|
||||
|
||||
$result = $field->validate();
|
||||
$this->assertFalse($result->isValid(), 'Validation should fail when min is greater than max');
|
||||
$this->assertStringContainsString('Minimum length should be less than the maximum length', $result->serialize());
|
||||
$this->assertStringContainsString('Minimum length should be less than the maximum length', json_encode($result->__serialize()));
|
||||
}
|
||||
|
||||
public function testValidate()
|
||||
|
@ -15,6 +15,7 @@ use SilverStripe\UserForms\Model\EditableFormField\EditableOption;
|
||||
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
|
||||
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
||||
use SilverStripe\UserForms\Model\UserDefinedForm;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* @package userforms
|
||||
@ -62,6 +63,9 @@ class EditableFormFieldTest extends FunctionalTest
|
||||
|
||||
public function testCustomRules()
|
||||
{
|
||||
if (Deprecation::isEnabled()) {
|
||||
$this->markTestSkipped('Test calls deprecated code');
|
||||
}
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$form = $this->objFromFixture(UserDefinedForm::class, 'custom-rules-form');
|
||||
|
||||
|
@ -40,7 +40,7 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Email::config()->update('admin_email', 'no-reply@example.com');
|
||||
Email::config()->set('admin_email', 'no-reply@example.com');
|
||||
}
|
||||
|
||||
public function testRollbackToVersion()
|
||||
@ -51,6 +51,7 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
|
||||
// @todo
|
||||
$this->logInWithPermission('ADMIN');
|
||||
/** @var UserDefinedForm|Versioned $form */
|
||||
$form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||
|
||||
$form->SubmitButtonText = 'Button Text';
|
||||
@ -66,7 +67,7 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
$updated = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
||||
$this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');
|
||||
|
||||
$form->doRollbackTo($origVersion);
|
||||
$form->rollbackRecursive($origVersion);
|
||||
|
||||
$orignal = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
||||
$this->assertEquals($orignal->SubmitButtonText, 'Button Text');
|
||||
@ -521,7 +522,7 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
{
|
||||
// Test that the $UserDefinedForm is stripped out
|
||||
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$result = $this->get($page->Link());
|
||||
$body = Convert::nl2os($result->getBody(), ''); // strip out newlines
|
||||
|
Loading…
Reference in New Issue
Block a user