Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Removed keyed arrays for title/value setting in SelectionGroup
Use SelectionGroup_Item class instead. Necessary because of removal of array key support from ArrayList (see d12b497).
- Loading branch information
Showing
4 changed files
with
175 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
class SelectionGroupTest extends SapphireTest { | ||
|
||
function testFieldHolder() { | ||
$items = array( | ||
new SelectionGroup_Item( | ||
'one', | ||
new LiteralField('one', 'one view'), | ||
'one title' | ||
), | ||
new SelectionGroup_Item( | ||
'two', | ||
new LiteralField('two', 'two view'), | ||
'two title' | ||
), | ||
); | ||
$field = new SelectionGroup('MyGroup', $items); | ||
$parser = new CSSContentParser($field->FieldHolder()); | ||
$listEls = $parser->getBySelector('li'); | ||
$listElOne = $listEls[0]; | ||
$listElTwo = $listEls[1]; | ||
|
||
$this->assertEquals('one', (string)$listElOne->input[0]['value']); | ||
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); | ||
|
||
$this->assertEquals('one title', $listElOne->label[0]); | ||
$this->assertEquals('two title', $listElTwo->label[0]); | ||
|
||
$this->assertContains('one view', (string)$listElOne); | ||
$this->assertContains('two view', (string)$listElTwo); | ||
} | ||
|
||
function testLegacyItemsFieldHolder() { | ||
$items = array( | ||
'one' => new LiteralField('one', 'one view'), | ||
'two' => new LiteralField('two', 'two view'), | ||
); | ||
$field = new SelectionGroup('MyGroup', $items); | ||
$parser = new CSSContentParser($field->FieldHolder()); | ||
$listEls = $parser->getBySelector('li'); | ||
$listElOne = $listEls[0]; | ||
$listElTwo = $listEls[1]; | ||
|
||
$this->assertEquals('one', (string)$listElOne->input[0]['value']); | ||
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); | ||
|
||
$this->assertEquals('one', $listElOne->label[0]); | ||
$this->assertEquals('two', $listElTwo->label[0]); | ||
} | ||
|
||
function testLegacyItemsFieldHolderWithTitle() { | ||
$items = array( | ||
'one//one title' => new LiteralField('one', 'one view'), | ||
'two//two title' => new LiteralField('two', 'two view'), | ||
); | ||
$field = new SelectionGroup('MyGroup', $items); | ||
$parser = new CSSContentParser($field->FieldHolder()); | ||
$listEls = $parser->getBySelector('li'); | ||
$listElOne = $listEls[0]; | ||
$listElTwo = $listEls[1]; | ||
|
||
$this->assertEquals('one', (string)$listElOne->input[0]['value']); | ||
$this->assertEquals('two', (string)$listElTwo->input[0]['value']); | ||
|
||
$this->assertEquals('one title', $listElOne->label[0]); | ||
$this->assertEquals('two title', $listElTwo->label[0]); | ||
} | ||
|
||
} |