diff options
Diffstat (limited to 'modules/system/system.test')
-rw-r--r-- | modules/system/system.test | 146 |
1 files changed, 134 insertions, 12 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index f40bd686a..abd21aae6 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1638,26 +1638,98 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase { function testThemeSettings() { // Specify a filesystem path to be used for the logo. $file = current($this->drupalGetTestFiles('image')); - $fullpath = drupal_realpath($file->uri); - $edit = array( - 'default_logo' => FALSE, - 'logo_path' => $fullpath, + $file_relative = strtr($file->uri, array('public:/' => variable_get('file_public_path', conf_path() . '/files'))); + $default_theme_path = 'themes/stark'; + + $supported_paths = array( + // Raw stream wrapper URI. + $file->uri => array( + 'form' => file_uri_target($file->uri), + 'src' => file_create_url($file->uri), + ), + // Relative path within the public filesystem. + file_uri_target($file->uri) => array( + 'form' => file_uri_target($file->uri), + 'src' => file_create_url($file->uri), + ), + // Relative path to a public file. + $file_relative => array( + 'form' => $file_relative, + 'src' => file_create_url($file->uri), + ), + // Relative path to an arbitrary file. + 'misc/druplicon.png' => array( + 'form' => 'misc/druplicon.png', + 'src' => $GLOBALS['base_url'] . '/' . 'misc/druplicon.png', + ), + // Relative path to a file in a theme. + $default_theme_path . '/logo.png' => array( + 'form' => $default_theme_path . '/logo.png', + 'src' => $GLOBALS['base_url'] . '/' . $default_theme_path . '/logo.png', + ), ); - $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); - $this->drupalGet('node'); - $this->assertRaw($fullpath, t('Logo path successfully changed.')); + foreach ($supported_paths as $input => $expected) { + $edit = array( + 'default_logo' => FALSE, + 'logo_path' => $input, + ); + $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); + $this->assertNoText('The custom logo path is invalid.'); + $this->assertFieldByName('logo_path', $expected['form']); + + // Verify the actual 'src' attribute of the logo being output. + $this->drupalGet(''); + $elements = $this->xpath('//*[@id=:id]/img', array(':id' => 'logo')); + $this->assertEqual((string) $elements[0]['src'], $expected['src']); + } + + $unsupported_paths = array( + // Stream wrapper URI to non-existing file. + 'public://whatever.png', + 'private://whatever.png', + 'temporary://whatever.png', + // Bogus stream wrapper URIs. + 'public:/whatever.png', + '://whatever.png', + ':whatever.png', + 'public://', + // Relative path within the public filesystem to non-existing file. + 'whatever.png', + // Relative path to non-existing file in public filesystem. + variable_get('file_public_path', conf_path() . '/files') . '/whatever.png', + // Semi-absolute path to non-existing file in public filesystem. + '/' . variable_get('file_public_path', conf_path() . '/files') . '/whatever.png', + // Relative path to arbitrary non-existing file. + 'misc/whatever.png', + // Semi-absolute path to arbitrary non-existing file. + '/misc/whatever.png', + // Absolute paths to any local file (even if it exists). + drupal_realpath($file->uri), + ); + $this->drupalGet('admin/appearance/settings'); + foreach ($unsupported_paths as $path) { + $edit = array( + 'default_logo' => FALSE, + 'logo_path' => $path, + ); + $this->drupalPost(NULL, $edit, t('Save configuration')); + $this->assertText('The custom logo path is invalid.'); + } // Upload a file to use for the logo. - $file = current($this->drupalGetTestFiles('image')); $edit = array( 'default_logo' => FALSE, 'logo_path' => '', 'files[logo_upload]' => drupal_realpath($file->uri), ); - $options = array(); - $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration'), $options); - $this->drupalGet('node'); - $this->assertRaw($file->name, t('Logo file successfully uploaded.')); + $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); + + $fields = $this->xpath($this->constructFieldXpath('name', 'logo_path')); + $uploaded_filename = 'public://' . $fields[0]['value']; + + $this->drupalGet(''); + $elements = $this->xpath('//*[@id=:id]/img', array(':id' => 'logo')); + $this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename)); } /** @@ -2239,6 +2311,56 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase { $final_theme_data = db_query("SELECT * FROM {system} WHERE type = 'theme' ORDER BY name")->fetchAll(); $this->assertEqual($original_theme_data, $final_theme_data, t('Visiting update.php does not alter the information about themes stored in the database.')); } + + /** + * Tests update.php when there are no updates to apply. + */ + function testNoUpdateFunctionality() { + // Click through update.php with 'administer software updates' permission. + $this->drupalLogin($this->update_user); + $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->assertText(t('No pending updates.')); + $this->assertNoLink('Administration pages'); + $this->clickLink('Front page'); + $this->assertResponse(200); + + // Click through update.php with 'access administration pages' permission. + $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages')); + $this->drupalLogin($admin_user); + $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->assertText(t('No pending updates.')); + $this->clickLink('Administration pages'); + $this->assertResponse(200); + } + + /** + * Tests update.php after performing a successful update. + */ + function testSuccessfulUpdateFunctionality() { + drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); + // Click through update.php with 'administer software updates' permission. + $this->drupalLogin($this->update_user); + $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalPost(NULL, array(), t('Apply pending updates')); + $this->assertText('Updates were attempted.'); + $this->assertLink('site'); + $this->assertNoLink('Administration pages'); + $this->assertNoLink('logged'); + $this->clickLink('Front page'); + $this->assertResponse(200); + + drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); + // Click through update.php with 'access administration pages' and + // 'access site reports' permissions. + $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports')); + $this->drupalLogin($admin_user); + $this->drupalPost($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->drupalPost(NULL, array(), t('Apply pending updates')); + $this->assertText('Updates were attempted.'); + $this->assertLink('logged'); + $this->clickLink('Administration pages'); + $this->assertResponse(200); + } } /** |