/** * {@inheritdoc} */ protected function setUpSyncForm() { // Create a new sync directory. drupal_mkdir($this->sync_dir); // Extract the tarball into the sync directory. $archiver = new ArchiveTar($this->tarball, 'gz'); $files = array(); foreach ($archiver->listContent() as $file) { $files[] = $file['filename']; } $archiver->extractList($files, $this->sync_dir); // Change the user.settings::register so that we can test that // standard_install() does not override it. $sync = new FileStorage($this->sync_dir); $user_settings = $sync->read('user.settings'); $user_settings['register'] = USER_REGISTER_ADMINISTRATORS_ONLY; $sync->write('user.settings', $user_settings); $this->drupalPostForm(NULL, array('sync_directory' => drupal_realpath($this->sync_dir)), 'Save and continue'); }
/** * {@inheritdoc} */ protected function update($name, $data) { $this->fileStorage->write($name, $data); $this->cache->set($name, $data); }
/** * Tests serialization of configuration to file. */ function testSerialization() { $name = $this->randomMachineName(10) . '.' . $this->randomMachineName(10); $config_data = array('numeric keys' => array('i', 'n', 'd', 'e', 'x', 'e', 'd'), 'nested keys' => array('HTML' => '<strong> <bold> <em> <blockquote>', 'UTF-8' => 'FrançAIS is ÜBER-åwesome', 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ' => 'αβγδεζηθικλμνξοσὠ'), 'invalid xml' => '</title><script type="text/javascript">alert("Title XSS!");</script> & < > " \' '); // Encode and write, and reload and decode the configuration data. $filestorage = new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY)); $filestorage->write($name, $config_data); $config_parsed = $filestorage->read($name); $key = 'numeric keys'; $this->assertIdentical($config_data[$key], $config_parsed[$key]); $key = 'nested keys'; $this->assertIdentical($config_data[$key], $config_parsed[$key]); $key = 'HTML'; $this->assertIdentical($config_data['nested keys'][$key], $config_parsed['nested keys'][$key]); $key = 'UTF-8'; $this->assertIdentical($config_data['nested keys'][$key], $config_parsed['nested keys'][$key]); $key = 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ'; $this->assertIdentical($config_data['nested keys'][$key], $config_parsed['nested keys'][$key]); $key = 'invalid xml'; $this->assertIdentical($config_data[$key], $config_parsed[$key]); }