public function DynamicBackgroundTestCase::testDynamicBackgroundConfiguration in Dynamic Background 7
File
- ./dynamic_background.test, line 38
Class
- DynamicBackgroundTestCase
Code
public function testDynamicBackgroundConfiguration() {
$conf = array();
$conf['dynamic_background_setting[num_of_pictures]'] = 4;
$conf['dynamic_background_setting[path]'] = 'db_images';
$conf['dynamic_background_setting[extensions]'] = 'jpg jpeg png';
$this
->drupalPost('admin/config/user-interface/backgrounds/settings', $conf, $this->btnSave);
$this
->assertText($this->msgSave);
$this
->assertFieldById('edit-dynamic-background-setting-num-of-pictures', '4', 'The number of upload fields is set corret.');
$this
->assertFieldById('edit-dynamic-background-setting-path', 'db_images', 'The upload path where corret.');
$this
->assertFieldById('edit-dynamic-background-setting-extensions', 'jpg jpeg png', 'The extensions where corret.');
$conf = array();
$conf['dynamic_background_css[custom]'] = TRUE;
$conf['dynamic_background_css[selector]'] = '#page #main-wrapper';
$conf['dynamic_background_css[css]'] = 'background-size: cover;';
$this
->drupalPost('admin/config/user-interface/backgrounds/settings', $conf, $this->btnSave);
$this
->assertText($this->msgSave);
$this
->assertFieldById('edit-dynamic-background-css-custom', TRUE, 'The custom styling have been checked.');
$this
->assertFieldById('edit-dynamic-background-css-selector', '#page #main-wrapper', 'The CSS selector was set.');
$this
->assertFieldById('edit-dynamic-background-css-css', 'background-size: cover;', 'Custom styling was saved correctly.');
$path = 'admin/config/user-interface/backgrounds';
$this
->drupalGet($path);
$this
->assertText(t('Background image 1'));
$this
->assertText(t('Background image 2'));
$this
->assertText(t('Background image 3'));
$this
->assertText(t('Background image 4'));
$file = realpath('misc/druplicon.png');
$this
->drupalPost('admin/config/user-interface/backgrounds', array(
'files[dynamic_background_picture_0]' => $file,
), $this->btnSave);
$saved = $this
->assertText($this->msgSave);
if ($saved) {
$this
->drupalPost('admin/config/user-interface/backgrounds', array(
'dynamic_background_picture_0[picture_use]' => TRUE,
), $this->btnSave);
$this
->assertText($this->msgSave);
$this
->assertFieldChecked('edit-dynamic-background-picture-0-picture-use', 'The firste image was selected.');
$this
->drupalPost('admin/config/user-interface/backgrounds', array(
'files[dynamic_background_picture_1]' => $file,
), $this->btnSave);
$this
->assertText(t('Failded to upload image, as one with that name exists.'));
$this
->drupalPost('admin/config/user-interface/backgrounds', array(
'dynamic_background_picture_0[picture_use]' => FALSE,
), $this->btnSave);
$this
->assertText($this->msgSave);
$this
->assertNoFieldChecked('edit-dynamic-background-picture-0-picture-use', 'The firste image should be de-selected.');
$this
->drupalPost('admin/config/user-interface/backgrounds', array(
'dynamic_background_picture_0[picture_delete]' => TRUE,
), $this->btnSave);
$this
->assertText($this->msgSave);
}
}