-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW Add new method TabSet::changeTabOrder(). (#11329)
- Loading branch information
1 parent
cdde36b
commit eee7a84
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms\Tests; | ||
|
||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\TabSet; | ||
|
||
class TabSetTest extends SapphireTest | ||
{ | ||
protected $usesDatabase = false; | ||
|
||
public function testChangeTabOrder(): void | ||
{ | ||
$tabSet = new TabSet('Root'); | ||
$fieldList = new FieldList([$tabSet]); | ||
$fieldList->findOrMakeTab('Root.Main'); | ||
$fieldList->findOrMakeTab('Root.Next'); | ||
$fieldList->findOrMakeTab('Root.More'); | ||
$fieldList->findOrMakeTab('Root.Extra'); | ||
$fieldList->addFieldToTab('Root', new TabSet('SubTabSet')); | ||
$fieldList->findOrMakeTab('Root.SubTabSet.Another'); | ||
|
||
// Reorder tabs - intentionally leaving some alone, which will be added to the end. | ||
$tabSet->changeTabOrder([ | ||
'SubTabSet', | ||
'More', | ||
'Main', | ||
'Non-Existent', // will be ignored | ||
'Another', // will be ignored | ||
]); | ||
// Order is correct | ||
$this->assertSame(['SubTabSet', 'More', 'Main', 'Next', 'Extra'], $tabSet->getChildren()->column('Name')); | ||
// Sub-tab is still there | ||
$this->assertNotNull($fieldList->findTab('Root.SubTabSet.Another')); | ||
} | ||
} |