mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #1075 from creative-commoners/pulls/5.8/fix-orphan-removal-test
MNT Fix testOrphanRemovalDoesNotAffectOtherClassesWithTheSameID to start with a First Page Step
This commit is contained in:
commit
2b249c29e2
@ -31,21 +31,20 @@ class UserFormFieldEditorExtensionTest extends SapphireTest
|
|||||||
|
|
||||||
// assert setup
|
// assert setup
|
||||||
$this->assertSame($page->ID, $block->ID);
|
$this->assertSame($page->ID, $block->ID);
|
||||||
$this->assertCount(1, $page->Fields());
|
$this->assertCount(2, $page->Fields(), 'Draft UserForm page starts with 2 fields');
|
||||||
$this->assertCount(3, $block->Fields());
|
$this->assertCount(3, $block->Fields(), 'Draft UserForm block starts with 3 fields');
|
||||||
|
|
||||||
// ensure setup has affected live mode too
|
// ensure setup has affected live mode too
|
||||||
$origReadingMode = Versioned::get_reading_mode();
|
$origReadingMode = Versioned::get_reading_mode();
|
||||||
|
Versioned::withVersionedMode(function () {
|
||||||
Versioned::set_reading_mode(Versioned::LIVE);
|
Versioned::set_reading_mode(Versioned::LIVE);
|
||||||
|
|
||||||
$initialLivePage = UserDefinedForm::get()->First();
|
$initialLivePage = UserDefinedForm::get()->First();
|
||||||
$initialLiveBlock = UserFormBlockStub::get()->First();
|
$initialLiveBlock = UserFormBlockStub::get()->First();
|
||||||
|
|
||||||
$this->assertSame($initialLivePage->ID, $initialLiveBlock->ID);
|
$this->assertSame($initialLivePage->ID, $initialLiveBlock->ID);
|
||||||
$this->assertCount(1, $initialLivePage->Fields());
|
$this->assertCount(2, $initialLivePage->Fields(), 'Live UserForm page starst with 2 fields');
|
||||||
$this->assertCount(3, $initialLiveBlock->Fields());
|
$this->assertCount(3, $initialLiveBlock->Fields(), 'Live UserForm block starst with 3 fields');
|
||||||
|
});
|
||||||
Versioned::set_reading_mode($origReadingMode);
|
|
||||||
|
|
||||||
// execute change
|
// execute change
|
||||||
$newField = new EditableEmailField();
|
$newField = new EditableEmailField();
|
||||||
@ -57,21 +56,32 @@ class UserFormFieldEditorExtensionTest extends SapphireTest
|
|||||||
$page->publishRecursive();
|
$page->publishRecursive();
|
||||||
|
|
||||||
// assert effect of change
|
// assert effect of change
|
||||||
|
/** @var UserDefinedForm $checkPage */
|
||||||
$checkPage = UserDefinedForm::get()->First();
|
$checkPage = UserDefinedForm::get()->First();
|
||||||
$checkBlock = UserFormBlockStub::get()->First();
|
$checkBlock = UserFormBlockStub::get()->First();
|
||||||
|
|
||||||
$this->assertCount(2, $checkPage->Fields());
|
$this->assertCount(3, $checkPage->Fields(), 'Field has been added to draft user form page');
|
||||||
$this->assertCount(3, $checkBlock->Fields());
|
$this->assertCount(
|
||||||
|
3,
|
||||||
|
$checkBlock->Fields(),
|
||||||
|
'Draft userform block with same ID is not affected'
|
||||||
|
);
|
||||||
|
|
||||||
// ensure this is true for live mode too
|
// ensure this is true for live mode too
|
||||||
$origReadingMode = Versioned::get_reading_mode();
|
Versioned::withVersionedMode(function () {
|
||||||
Versioned::set_reading_mode(Versioned::LIVE);
|
Versioned::set_reading_mode(Versioned::LIVE);
|
||||||
|
|
||||||
$checkLivePage = UserDefinedForm::get()->First();
|
$checkLivePage = UserDefinedForm::get()->First();
|
||||||
$checkLiveBlock = UserFormBlockStub::get()->First();
|
$checkLiveBlock = UserFormBlockStub::get()->First();
|
||||||
$this->assertCount(2, $checkLivePage->Fields());
|
$this->assertCount(
|
||||||
$this->assertCount(3, $checkLiveBlock->Fields());
|
3,
|
||||||
|
$checkLivePage->Fields(),
|
||||||
Versioned::set_reading_mode($origReadingMode);
|
'Field has been added to live user form page'
|
||||||
|
);
|
||||||
|
$this->assertCount(
|
||||||
|
3,
|
||||||
|
$checkLiveBlock->Fields(),
|
||||||
|
'Live userform block with same ID is not affected'
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,12 @@ SilverStripe\UserForms\Model\UserDefinedForm:
|
|||||||
SilverStripe\UserForms\Tests\Extension\UserFormBlockStub:
|
SilverStripe\UserForms\Tests\Extension\UserFormBlockStub:
|
||||||
block:
|
block:
|
||||||
ID: 9999
|
ID: 9999
|
||||||
|
|
||||||
|
SilverStripe\UserForms\Model\EditableFormField\EditableFormStep:
|
||||||
|
pageFirstStep:
|
||||||
|
Title: First Step
|
||||||
|
Parent: =>SilverStripe\UserForms\Model\UserDefinedForm.page
|
||||||
|
|
||||||
SilverStripe\UserForms\Model\EditableFormField\EditableTextField:
|
SilverStripe\UserForms\Model\EditableFormField\EditableTextField:
|
||||||
page-text-field:
|
page-text-field:
|
||||||
Name: basic_text_name
|
Name: basic_text_name
|
||||||
|
Loading…
Reference in New Issue
Block a user