MINOR: Replaced usage of deprecated toDropdownMap() with map().

This commit is contained in:
ajshort 2011-05-03 13:05:27 +10:00
parent 14c57ae082
commit c025ce7a4a
4 changed files with 9 additions and 18 deletions

View File

@ -51,7 +51,7 @@ class TableFieldTest extends SapphireTest {
$tableField->saveInto($group);
// Let's check that the 2 permissions entries have been saved
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
$permissions = $group->Permissions()->map('Arg', 'Code');
$this->assertEquals(array(
1 => 'CustomPerm1',
2 => 'CustomPerm2',
@ -75,7 +75,7 @@ class TableFieldTest extends SapphireTest {
$tableField->saveInto($group);
// Let's check that the 2 existing permissions entries, and the 1 new one, have been saved
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
$permissions = $group->Permissions()->map('Arg', 'Code');
$this->assertEquals(array(
1 => 'CustomPerm1',
2 => 'CustomPerm2',
@ -126,7 +126,7 @@ class TableFieldTest extends SapphireTest {
$tableField->saveInto($group);
// Let's check that the 2 permissions entries have been saved
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
$permissions = $group->Permissions()->map('Arg', 'Code');
$this->assertEquals(array(
101 => 'Perm1 Modified',
102 => 'Perm2 Modified',

View File

@ -52,7 +52,7 @@ class TableListFieldTest extends SapphireTest {
$items = $table->sourceItems();
$this->assertNotNull($items);
$itemMap = $items->toDropdownMap("ID", "A") ;
$itemMap = $items->map("ID", "A") ;
$this->assertEquals(array(
$item1->ID => "a1",
$item2->ID => "a2",
@ -88,7 +88,7 @@ class TableListFieldTest extends SapphireTest {
$items = $table->sourceItems();
$this->assertNotNull($items);
$itemMap = $items->toDropdownMap("ID", "A") ;
$itemMap = $items->map("ID", "A") ;
$this->assertEquals(array(
$item1->ID => "a1",
$item2->ID => "a2"
@ -122,7 +122,7 @@ class TableListFieldTest extends SapphireTest {
$items = $table->sourceItems();
$this->assertNotNull($items);
$itemMap = $items->toDropdownMap("ID", "A") ;
$itemMap = $items->map("ID", "A") ;
$this->assertEquals(array($item3->ID => "a3", $item4->ID => "a4"), $itemMap);
}

View File

@ -177,25 +177,16 @@ class DataObjectSetTest extends SapphireTest {
$comments = DataObject::get('DataObjectSetTest_TeamComment', '', "\"ID\" ASC");
/* Now we get a map of all the PageComment records */
$map = $comments->map('ID', 'Title', '(Select one)');
$map = $comments->map('ID', 'Title');
$expectedMap = array(
'' => '(Select one)',
1 => 'Joe',
2 => 'Bob',
3 => 'Phil'
);
/* There are 9 items in the map. 3 are records. 1 is the empty value */
$this->assertEquals(count($map), 4, 'There are 4 items in the map. 3 are records. 1 is the empty value');
/* We have the same map as our expected map, asserted above */
/* toDropDownMap() is an alias of map() - let's make a map from that */
$map2 = $comments->toDropDownMap('ID', 'Title', '(Select one)');
/* There are 4 items in the map. 3 are records. 1 is the empty value */
$this->assertEquals(count($map), 4, 'There are 4 items in the map. 3 are records. 1 is the empty value.');
$this->assertEquals(count($map), 3, 'There are 3 items in the map.');
}
function testRemoveDuplicates() {

View File

@ -128,7 +128,7 @@ class GroupTest_Member extends Member implements TestOnly {
function getCMSFields() {
$groups = DataObject::get('Group');
$groupsMap = ($groups) ? $groups->toDropDownMap() : false;
$groupsMap = ($groups) ? $groups->map() : false;
$fields = new FieldSet(
new HiddenField('ID', 'ID'),
new CheckboxSetField(