public function DynamicBackgroundTestCase::testDynamicBackgroundConfiguration in Dynamic Background 7
File
- ./
dynamic_background.test, line 38
Class
Code
public function testDynamicBackgroundConfiguration() {
// Set configuring options.
$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);
// Test that the configuration where saved.
$this
->assertText($this->msgSave);
// Test that the right value where saved.
$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.');
// Test custom CSS settings.
$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);
// Test that the configuration was saved, with the right values.
$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.');
// Test that the upload page is correct.
$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'));
// Test that images can be uploaded.
$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);
// Test that image can be select.
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.');
// Test that the same file can not be upload again.
$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.'));
// Test that image can be deleted.
$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);
}
}