ENHANCEMENT Added FieldSet->hasTabSet() incl. unit test

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63628 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-03 18:29:43 +00:00
parent 7ab2748034
commit 21859d3d97
2 changed files with 25 additions and 0 deletions

View File

@ -198,6 +198,19 @@ class FieldSet extends DataObjectSet {
return false;
}
/**
* @return boolean
*/
public function hasTabSet() {
foreach($this->items as $i => $field) {
if(is_object($field) && $field instanceof TabSet) {
return true;
}
}
return false;
}
/**
* Returns the specified tab object, creating it if necessary.
*

View File

@ -89,6 +89,18 @@ class FieldSetTest extends SapphireTest {
$this->assertEquals($tab1, $fields->fieldByName('Root')->fieldByName('Tab1'));
}
function testHasTabSet() {
$untabbedFields = new FieldSet(
new TextField('Field1')
);
$this->assertFalse($untabbedFields->hasTabSet());
$tabbedFields = new FieldSet(new TabSet(
new Tab('Tab1')
));
$this->assertTrue($tabbedFields->hasTabSet());
}
/**
* Test removing an array of fields from a tab in a set.
*/