Test picture administration functionality.
public function testPictureAdmin() {
// We start without any default mappings.
$this
->drupalGet('admin/config/media/picturemapping');
$this
->assertText('There is no Picture mapping yet.');
// Add a new picture mapping, our breakpoint set should be selected.
$this
->drupalGet('admin/config/media/picturemapping/add');
$this
->assertFieldByName('breakpointGroup', 'atestset');
// Create a new group.
$edit = array(
'label' => 'Mapping One',
'id' => 'mapping_one',
'breakpointGroup' => 'atestset',
);
$this
->drupalPost('admin/config/media/picturemapping/add', $edit, t('Save'));
// Check if the new group is created.
$this
->assertResponse(200);
$this
->drupalGet('admin/config/media/picturemapping');
$this
->assertNoText('There is no Picture mapping yet.');
$this
->assertText('Mapping One');
$this
->assertText('mapping_one');
// Edit the group.
$this
->drupalGet('admin/config/media/picturemapping/mapping_one/edit');
$this
->assertFieldByName('label', 'Mapping One');
$this
->assertFieldByName('breakpointGroup', 'atestset');
// Check if the dropdows are present for the mappings.
$this
->assertFieldByName('mappings[custom.user.small][1x]', '');
$this
->assertFieldByName('mappings[custom.user.small][2x]', '');
$this
->assertFieldByName('mappings[custom.user.medium][1x]', '');
$this
->assertFieldByName('mappings[custom.user.medium][2x]', '');
$this
->assertFieldByName('mappings[custom.user.large][1x]', '');
$this
->assertFieldByName('mappings[custom.user.large][2x]', '');
// Save mappings for 1x variant only.
$edit = array(
'label' => 'Mapping One',
'breakpointGroup' => 'atestset',
'mappings[custom.user.small][1x]' => 'thumbnail',
'mappings[custom.user.medium][1x]' => 'medium',
'mappings[custom.user.large][1x]' => 'large',
);
$this
->drupalPost('admin/config/media/picturemapping/mapping_one/edit', $edit, t('Save'));
$this
->drupalGet('admin/config/media/picturemapping/mapping_one/edit');
$this
->assertFieldByName('mappings[custom.user.small][1x]', 'thumbnail');
$this
->assertFieldByName('mappings[custom.user.small][2x]', '');
$this
->assertFieldByName('mappings[custom.user.medium][1x]', 'medium');
$this
->assertFieldByName('mappings[custom.user.medium][2x]', '');
$this
->assertFieldByName('mappings[custom.user.large][1x]', 'large');
$this
->assertFieldByName('mappings[custom.user.large][2x]', '');
// Delete the mapping.
$this
->drupalGet('admin/config/media/picturemapping/mapping_one/delete');
$this
->drupalPost(NULL, array(), t('Delete'));
$this
->drupalGet('admin/config/media/picturemapping');
$this
->assertText('There is no Picture mapping yet.');
}