-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Various changes to support SiteTree form field scaffolding
- Loading branch information
1 parent
051dadd
commit 535cb46
Showing
5 changed files
with
76 additions
and
30 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
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
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,30 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms\Tests; | ||
|
||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\Forms\Tab; | ||
|
||
class TabTest extends SapphireTest | ||
{ | ||
protected $usesDatabase = false; | ||
|
||
public function testNameAndID(): void | ||
{ | ||
// ID is set on instantiation based on the name | ||
$tab = new Tab('MyName _-()!@#$'); | ||
$this->assertSame('MyName _-()!@#$', $tab->getName()); | ||
$this->assertSame('MyName_-', $tab->ID()); | ||
|
||
// Changing the name changes the ID | ||
$tab->setName('NewName'); | ||
$this->assertSame('NewName', $tab->getName()); | ||
$this->assertSame('NewName', $tab->ID()); | ||
|
||
// If ID is explicitly set, changing the name doesn't override it | ||
$tab->setID('Custom-ID'); | ||
$tab->setName('AnotherName'); | ||
$this->assertSame('AnotherName', $tab->getName()); | ||
$this->assertSame('Custom-ID', $tab->ID()); | ||
} | ||
} |