mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-29 22:16:01 +02:00
ENHANCEMENT Supporting recursion into nested sets in FieldSet->insertAfter()/TabSet->insertAfter()/CompositeField->insertAfter() API CHANGE Deprecated CompositeField->insertBeforeRecursive(), use CompositeField->insertBefore() ENHANCEMENT Renamed CompositeField->beforeInsert() to CompositeField->onBeforeInsert() to avoid confusion with insertBefore() ENHANCEMENT Added CompositeFieldTest ENHANCEMENT Added unit tests for FieldSet->insertBefore()/insertAfter() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65581 467b73ca-7a2a-4603-9d3b-597d59a354a9
33 lines
931 B
PHP
33 lines
931 B
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage tests
|
|
*/
|
|
class CompositeFieldTest extends SapphireTest {
|
|
|
|
function testFieldPosition() {
|
|
$compositeOuter = new CompositeField(
|
|
new TextField('A'),
|
|
new TextField('B'),
|
|
$compositeInner = new CompositeField(
|
|
new TextField('C1'),
|
|
new TextField('C2')
|
|
),
|
|
new TextField('D')
|
|
);
|
|
|
|
$this->assertEquals(0, $compositeOuter->fieldPosition('A'));
|
|
$this->assertEquals(1, $compositeOuter->fieldPosition('B'));
|
|
$this->assertEquals(3, $compositeOuter->fieldPosition('D'));
|
|
|
|
$this->assertEquals(0, $compositeInner->fieldPosition('C1'));
|
|
$this->assertEquals(1, $compositeInner->fieldPosition('C2'));
|
|
|
|
$compositeOuter->insertBefore(new TextField('AB'), 'B');
|
|
$this->assertEquals(0, $compositeOuter->fieldPosition('A'));
|
|
$this->assertEquals(1, $compositeOuter->fieldPosition('AB'));
|
|
$this->assertEquals(2, $compositeOuter->fieldPosition('B'));
|
|
}
|
|
|
|
}
|
|
?>
|