Commit 870b5646 authored by larowlan's avatar larowlan

Issue #3021434 by voleger, Peter Majmesku, andypost, Berdir, kim.pepper:...

Issue #3021434 by voleger, Peter Majmesku, andypost, Berdir, kim.pepper: Properly deprecate drupal_unlink()
parent 073cc74c
...@@ -1091,12 +1091,14 @@ function drupal_chmod($uri, $mode = NULL) { ...@@ -1091,12 +1091,14 @@ function drupal_chmod($uri, $mode = NULL) {
/** /**
* Deletes a file. * Deletes a file.
* *
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::unlink(). * Use \Drupal\Core\File\FileSystem::unlink().
* *
* @see \Drupal\Core\File\FileSystem::unlink()
* @see https://www.drupal.org/node/2418133 * @see https://www.drupal.org/node/2418133
*/ */
function drupal_unlink($uri, $context = NULL) { function drupal_unlink($uri, $context = NULL) {
@trigger_error('drupal_unlink() is deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::unlink(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->unlink($uri, $context); return \Drupal::service('file_system')->unlink($uri, $context);
} }
......
...@@ -2085,6 +2085,7 @@ function install_check_requirements($install_state) { ...@@ -2085,6 +2085,7 @@ function install_check_requirements($install_state) {
'description_default' => t('The default settings file does not exist.'), 'description_default' => t('The default settings file does not exist.'),
'title' => t('Settings file'), 'title' => t('Settings file'),
]; ];
$file_system = \Drupal::service('file_system');
foreach ($default_files as $default_file_info) { foreach ($default_files as $default_file_info) {
$readable = FALSE; $readable = FALSE;
...@@ -2146,7 +2147,7 @@ function install_check_requirements($install_state) { ...@@ -2146,7 +2147,7 @@ function install_check_requirements($install_state) {
// file we just created and force the administrator to log on to the // file we just created and force the administrator to log on to the
// server and create it manually. // server and create it manually.
else { else {
$deleted = @drupal_unlink($file); $deleted = @$file_system->unlink($file);
// We expect deleting the file to be successful (since we just // We expect deleting the file to be successful (since we just
// created it ourselves above), but if it fails somehow, we set a // created it ourselves above), but if it fails somehow, we set a
// variable so we can display a one-time error message to the // variable so we can display a one-time error message to the
......
...@@ -411,7 +411,7 @@ public function move($source, $destination, $replace = self::EXISTS_RENAME) { ...@@ -411,7 +411,7 @@ public function move($source, $destination, $replace = self::EXISTS_RENAME) {
if (!@rename($real_source, $real_destination)) { if (!@rename($real_source, $real_destination)) {
// Fall back to slow copy and unlink procedure. This is necessary for // Fall back to slow copy and unlink procedure. This is necessary for
// renames across schemes that are not local, or where rename() has not // renames across schemes that are not local, or where rename() has not
// been implemented. It's not necessary to use drupal_unlink() as the // been implemented. It's not necessary to use FileSystem::unlink() as the
// Windows issue has already been resolved above. // Windows issue has already been resolved above.
if (!@copy($real_source, $real_destination)) { if (!@copy($real_source, $real_destination)) {
$this->logger->error("The specified file '%source' could not be moved to '%destination'.", [ $this->logger->error("The specified file '%source' could not be moved to '%destination'.", [
......
...@@ -2,11 +2,35 @@ ...@@ -2,11 +2,35 @@
namespace Drupal\Core\FileTransfer; namespace Drupal\Core\FileTransfer;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\File\FileSystemInterface;
/** /**
* Defines the local connection class for copying files as the httpd user. * Defines the local connection class for copying files as the httpd user.
*/ */
class Local extends FileTransfer implements ChmodInterface { class Local extends FileTransfer implements ChmodInterface {
use DependencySerializationTrait;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
public function __construct($jail, FileSystemInterface $file_system = NULL) {
parent::__construct($jail);
if (!isset($file_system)) {
@trigger_error('The $file_system parameter was added in Drupal 8.8.0 and will be required in 9.0.0. See https://www.drupal.org/node/3021434.', E_USER_DEPRECATED);
$file_system = \Drupal::service('file_system');
}
$this->fileSystem = $file_system;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -18,7 +42,7 @@ public function connect() { ...@@ -18,7 +42,7 @@ public function connect() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function factory($jail, $settings) { public static function factory($jail, $settings) {
return new Local($jail); return new Local($jail, \Drupal::service('file_system'));
} }
/** /**
...@@ -56,7 +80,7 @@ protected function removeDirectoryJailed($directory) { ...@@ -56,7 +80,7 @@ protected function removeDirectoryJailed($directory) {
} }
} }
elseif ($file->isFile()) { elseif ($file->isFile()) {
if (@!drupal_unlink($filename)) { if (@!$this->fileSystem->unlink($filename)) {
throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $filename]); throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $filename]);
} }
} }
...@@ -70,7 +94,7 @@ protected function removeDirectoryJailed($directory) { ...@@ -70,7 +94,7 @@ protected function removeDirectoryJailed($directory) {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function removeFileJailed($file) { protected function removeFileJailed($file) {
if (@!drupal_unlink($file)) { if (@!$this->fileSystem->unlink($file)) {
throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $file]); throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $file]);
} }
} }
......
...@@ -374,7 +374,7 @@ public function stream_truncate($new_size) { ...@@ -374,7 +374,7 @@ public function stream_truncate($new_size) {
*/ */
public function unlink($uri) { public function unlink($uri) {
$this->uri = $uri; $this->uri = $uri;
return drupal_unlink($this->getLocalPath()); return $this->getFileSystem()->unlink($this->getLocalPath());
} }
/** /**
...@@ -572,4 +572,14 @@ public function dir_closedir() { ...@@ -572,4 +572,14 @@ public function dir_closedir() {
return TRUE; return TRUE;
} }
/**
* Returns file system service.
*
* @return \Drupal\Core\File\FileSystemInterface
* The file system service.
*/
private function getFileSystem() {
return \Drupal::service('file_system');
}
} }
...@@ -424,11 +424,12 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { ...@@ -424,11 +424,12 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
} }
} }
$file_system = \Drupal::service('file_system');
// Delete old files. // Delete old files.
$files = $config->get('files'); $files = $config->get('files');
if (isset($files)) { if (isset($files)) {
foreach ($files as $file) { foreach ($files as $file) {
@drupal_unlink($file); @$file_system->unlink($file);
} }
} }
if (isset($file) && $file = dirname($file)) { if (isset($file) && $file = dirname($file)) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Drupal\Core\Archiver\ArchiveTar; use Drupal\Core\Archiver\ArchiveTar;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -22,14 +23,28 @@ class ConfigImportForm extends FormBase { ...@@ -22,14 +23,28 @@ class ConfigImportForm extends FormBase {
*/ */
protected $configStorage; protected $configStorage;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/** /**
* Constructs a new ConfigImportForm. * Constructs a new ConfigImportForm.
* *
* @param \Drupal\Core\Config\StorageInterface $config_storage * @param \Drupal\Core\Config\StorageInterface $config_storage
* The configuration storage. * The configuration storage.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system service.
*/ */
public function __construct(StorageInterface $config_storage) { public function __construct(StorageInterface $config_storage, FileSystemInterface $file_system = NULL) {
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
if (!isset($file_system)) {
@trigger_error('The $file_system parameter was added in Drupal 8.8.0 and will be required in 9.0.0. See https://www.drupal.org/node/3021434.', E_USER_DEPRECATED);
$file_system = \Drupal::service('file_system');
}
$this->fileSystem = $file_system;
} }
/** /**
...@@ -37,7 +52,8 @@ public function __construct(StorageInterface $config_storage) { ...@@ -37,7 +52,8 @@ public function __construct(StorageInterface $config_storage) {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.storage.sync') $container->get('config.storage.sync'),
$container->get('file_system')
); );
} }
...@@ -106,7 +122,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -106,7 +122,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
catch (\Exception $e) { catch (\Exception $e) {
$this->messenger()->addError($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()])); $this->messenger()->addError($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()]));
} }
drupal_unlink($path); $this->fileSystem->unlink($path);
} }
} }
......
...@@ -106,7 +106,7 @@ public function testFileValidateImageResolution() { ...@@ -106,7 +106,7 @@ public function testFileValidateImageResolution() {
$errors = file_validate_image_resolution($this->image, '-10x-5'); $errors = file_validate_image_resolution($this->image, '-10x-5');
$this->assertEqual(count($errors), 1, 'An error reported for an oversized image that can not be scaled down.', 'File'); $this->assertEqual(count($errors), 1, 'An error reported for an oversized image that can not be scaled down.', 'File');
drupal_unlink('temporary://druplicon.png'); \Drupal::service('file_system')->unlink('temporary://druplicon.png');
} }
else { else {
// TODO: should check that the error is returned if no toolkit is available. // TODO: should check that the error is returned if no toolkit is available.
......
...@@ -41,15 +41,16 @@ protected function setUp() { ...@@ -41,15 +41,16 @@ protected function setUp() {
* Test exportation of translations. * Test exportation of translations.
*/ */
public function testExportTranslation() { public function testExportTranslation() {
$file_system = \Drupal::service('file_system');
// First import some known translations. // First import some known translations.
// This will also automatically add the 'fr' language. // This will also automatically add the 'fr' language.
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po'; $name = $file_system->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $this->getPoFile()); file_put_contents($name, $this->getPoFile());
$this->drupalPostForm('admin/config/regional/translate/import', [ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'fr', 'langcode' => 'fr',
'files[file]' => $name, 'files[file]' => $name,
], t('Import')); ], t('Import'));
drupal_unlink($name); $file_system->unlink($name);
// Get the French translations. // Get the French translations.
$this->drupalPostForm('admin/config/regional/translate/export', [ $this->drupalPostForm('admin/config/regional/translate/export', [
...@@ -62,14 +63,14 @@ public function testExportTranslation() { ...@@ -62,14 +63,14 @@ public function testExportTranslation() {
$this->assertRaw('msgstr "lundi"', 'French translations present in exported file.'); $this->assertRaw('msgstr "lundi"', 'French translations present in exported file.');
// Import some more French translations which will be marked as customized. // Import some more French translations which will be marked as customized.
$name = \Drupal::service('file_system')->tempnam('temporary://', "po2_") . '.po'; $name = $file_system->tempnam('temporary://', "po2_") . '.po';
file_put_contents($name, $this->getCustomPoFile()); file_put_contents($name, $this->getCustomPoFile());
$this->drupalPostForm('admin/config/regional/translate/import', [ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'fr', 'langcode' => 'fr',
'files[file]' => $name, 'files[file]' => $name,
'customized' => 1, 'customized' => 1,
], t('Import')); ], t('Import'));
drupal_unlink($name); $file_system->unlink($name);
// Create string without translation in the locales_source table. // Create string without translation in the locales_source table.
$this->container $this->container
......
...@@ -374,11 +374,12 @@ public function testCreatedLanguageTranslation() { ...@@ -374,11 +374,12 @@ public function testCreatedLanguageTranslation() {
* (optional) Additional options to pass to the translation import form. * (optional) Additional options to pass to the translation import form.
*/ */
public function importPoFile($contents, array $options = []) { public function importPoFile($contents, array $options = []) {
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po'; $file_system = \Drupal::service('file_system');
$name = $file_system->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $contents); file_put_contents($name, $contents);
$options['files[file]'] = $name; $options['files[file]'] = $name;
$this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import')); $this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import'));
drupal_unlink($name); $file_system->unlink($name);
} }
/** /**
......
...@@ -352,11 +352,12 @@ public function testPluralEditExport() { ...@@ -352,11 +352,12 @@ public function testPluralEditExport() {
* Additional options to pass to the translation import form. * Additional options to pass to the translation import form.
*/ */
public function importPoFile($contents, array $options = []) { public function importPoFile($contents, array $options = []) {
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po'; $file_system = \Drupal::service('file_system');
$name = $file_system->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $contents); file_put_contents($name, $contents);
$options['files[file]'] = $name; $options['files[file]'] = $name;
$this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import')); $this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import'));
drupal_unlink($name); $file_system->unlink($name);
} }
/** /**
......
...@@ -192,6 +192,7 @@ protected function assertTwigTransTags() { ...@@ -192,6 +192,7 @@ protected function assertTwigTransTags() {
* Helper function: install languages. * Helper function: install languages.
*/ */
protected function installLanguages() { protected function installLanguages() {
$file_system = \Drupal::service('file_system');
foreach ($this->languages as $langcode => $name) { foreach ($this->languages as $langcode => $name) {
// Generate custom .po contents for the language. // Generate custom .po contents for the language.
$contents = $this->poFileContents($langcode); $contents = $this->poFileContents($langcode);
...@@ -209,7 +210,7 @@ protected function installLanguages() { ...@@ -209,7 +210,7 @@ protected function installLanguages() {
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.'); $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
// Import the custom .po contents for the language. // Import the custom .po contents for the language.
$filename = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po'; $filename = $file_system->tempnam('temporary://', "po_") . '.po';
file_put_contents($filename, $contents); file_put_contents($filename, $contents);
$options = [ $options = [
'files[file]' => $filename, 'files[file]' => $filename,
...@@ -217,7 +218,7 @@ protected function installLanguages() { ...@@ -217,7 +218,7 @@ protected function installLanguages() {
'customized' => TRUE, 'customized' => TRUE,
]; ];
$this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import')); $this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import'));
drupal_unlink($filename); $file_system->unlink($filename);
} }
} }
$this->container->get('language_manager')->reset(); $this->container->get('language_manager')->reset();
......
...@@ -234,7 +234,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -234,7 +234,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// update_authorize_run_install() directly. // update_authorize_run_install() directly.
if (fileowner($project_real_location) == fileowner($this->sitePath) && !$test_authorize) { if (fileowner($project_real_location) == fileowner($this->sitePath) && !$test_authorize) {
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
$filetransfer = new Local($this->root); $filetransfer = new Local($this->root, \Drupal::service('file_system'));
$response = call_user_func_array('update_authorize_run_install', array_merge([$filetransfer], $arguments)); $response = call_user_func_array('update_authorize_run_install', array_merge([$filetransfer], $arguments));
if ($response instanceof Response) { if ($response instanceof Response) {
$form_state->setResponse($response); $form_state->setResponse($response);
......
...@@ -153,7 +153,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -153,7 +153,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// and invoke update_authorize_run_update() directly. // and invoke update_authorize_run_update() directly.
if (fileowner($project_real_location) == fileowner($this->sitePath)) { if (fileowner($project_real_location) == fileowner($this->sitePath)) {
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
$filetransfer = new Local($this->root); $filetransfer = new Local($this->root, \Drupal::service('file_system'));
$response = update_authorize_run_update($filetransfer, $updates); $response = update_authorize_run_update($filetransfer, $updates);
if ($response instanceof Response) { if ($response instanceof Response) {
$form_state->setResponse($response); $form_state->setResponse($response);
......
...@@ -22,7 +22,7 @@ class TestFileTransferWithSettingsForm extends Local { ...@@ -22,7 +22,7 @@ class TestFileTransferWithSettingsForm extends Local {
* A new Drupal\update_test\TestFileTransferWithSettingsForm object. * A new Drupal\update_test\TestFileTransferWithSettingsForm object.
*/ */
public static function factory($jail, $settings) { public static function factory($jail, $settings) {
return new static($jail); return new static($jail, \Drupal::service('file_system'));
} }
/** /**
......
...@@ -309,6 +309,7 @@ function update_manager_batch_project_get($project, $url, &$context) { ...@@ -309,6 +309,7 @@ function update_manager_batch_project_get($project, $url, &$context) {
* @see install_check_requirements() * @see install_check_requirements()
*/ */
function update_manager_local_transfers_allowed() { function update_manager_local_transfers_allowed() {
$file_system = \Drupal::service('file_system');
// Compare the owner of a webserver-created temporary file to the owner of // Compare the owner of a webserver-created temporary file to the owner of
// the configuration directory to determine if local transfers will be // the configuration directory to determine if local transfers will be
// allowed. // allowed.
...@@ -318,7 +319,7 @@ function update_manager_local_transfers_allowed() { ...@@ -318,7 +319,7 @@ function update_manager_local_transfers_allowed() {
// Clean up. If this fails, we can ignore it (since this is just a temporary // Clean up. If this fails, we can ignore it (since this is just a temporary
// file anyway). // file anyway).
@drupal_unlink($temporary_file); @$file_system->unlink($temporary_file);
return $local_transfers_allowed; return $local_transfers_allowed;
} }
...@@ -72,7 +72,7 @@ public function testFileCheckDirectoryHandling() { ...@@ -72,7 +72,7 @@ public function testFileCheckDirectoryHandling() {
// Make sure directory actually exists. // Make sure directory actually exists.
$this->assertTrue(is_dir($directory), 'Directory actually exists.', 'File'); $this->assertTrue(is_dir($directory), 'Directory actually exists.', 'File');
$file_system = \Drupal::service('file_system');
if (substr(PHP_OS, 0, 3) != 'WIN') { if (substr(PHP_OS, 0, 3) != 'WIN') {
// PHP on Windows doesn't support any kind of useful read-only mode for // PHP on Windows doesn't support any kind of useful read-only mode for
// directories. When executing a chmod() on a directory, PHP only sets the // directories. When executing a chmod() on a directory, PHP only sets the
...@@ -92,7 +92,7 @@ public function testFileCheckDirectoryHandling() { ...@@ -92,7 +92,7 @@ public function testFileCheckDirectoryHandling() {
$this->assertDirectoryPermissions($directory, 0777, 'file_chmod_directory setting is respected.'); $this->assertDirectoryPermissions($directory, 0777, 'file_chmod_directory setting is respected.');
// Remove .htaccess file to then test that it gets re-created. // Remove .htaccess file to then test that it gets re-created.
@drupal_unlink(file_default_scheme() . '://.htaccess'); @$file_system->unlink(file_default_scheme() . '://.htaccess');
$this->assertFalse(is_file(file_default_scheme() . '://.htaccess'), 'Successfully removed the .htaccess file in the files directory.', 'File'); $this->assertFalse(is_file(file_default_scheme() . '://.htaccess'), 'Successfully removed the .htaccess file in the files directory.', 'File');
file_ensure_htaccess(); file_ensure_htaccess();
$this->assertTrue(is_file(file_default_scheme() . '://.htaccess'), 'Successfully re-created the .htaccess file in the files directory.', 'File'); $this->assertTrue(is_file(file_default_scheme() . '://.htaccess'), 'Successfully re-created the .htaccess file in the files directory.', 'File');
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\KernelTests\Core\File; namespace Drupal\KernelTests\Core\File;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use org\bovigo\vfs\vfsStream;
/** /**
* Tests deprecations in file.inc. * Tests deprecations in file.inc.
...@@ -146,4 +147,19 @@ public function testDeprecatedDrupalTempnam() { ...@@ -146,4 +147,19 @@ public function testDeprecatedDrupalTempnam() {
$this->assertNotNull(drupal_tempnam('temporary://', 'file')); $this->assertNotNull(drupal_tempnam('temporary://', 'file'));
} }
/**
* Tests deprecation of the drupal_unlink() function.
*
* @expectedDeprecation drupal_unlink() is deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::unlink(). See https://www.drupal.org/node/2418133.
*/
public function testUnlink() {
vfsStream::setup('dir');
vfsStream::create(['test.txt' => 'asdf']);
$uri = 'vfs://dir/test.txt';
$this->assertFileExists($uri);
drupal_unlink($uri);
$this->assertFileNotExists($uri);
}
} }
...@@ -46,6 +46,7 @@ public function testReadOnlyBehavior() { ...@@ -46,6 +46,7 @@ public function testReadOnlyBehavior() {
$uri = $this->scheme . '://' . $filename; $uri = $this->scheme . '://' . $filename;
\Drupal::service('stream_wrapper_manager')->getViaScheme($this->scheme); \Drupal::service('stream_wrapper_manager')->getViaScheme($this->scheme);
$file_system = \Drupal::service('file_system');
// Attempt to open a file in read/write mode // Attempt to open a file in read/write mode
$handle = @fopen($uri, 'r+'); $handle = @fopen($uri, 'r+');
$this->assertFalse($handle, 'Unable to open a file for reading and writing with the read-only stream wrapper.'); $this->assertFalse($handle, 'Unable to open a file for reading and writing with the read-only stream wrapper.');
...@@ -79,7 +80,7 @@ public function testReadOnlyBehavior() { ...@@ -79,7 +80,7 @@ public function testReadOnlyBehavior() {
// Test the rename() function // Test the rename() function
$this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.'); $this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.');
// Test the unlink() function // Test the unlink() function
$this->assertTrue(@drupal_unlink($uri), 'Able to unlink file using read-only stream wrapper.'); $this->assertTrue(@$file_system->unlink($uri), 'Able to unlink file using read-only stream wrapper.');
$this->assertTrue(file_exists($filepath), 'Unlink File was not actually deleted.'); $this->assertTrue(file_exists($filepath), 'Unlink File was not actually deleted.');
// Test the mkdir() function by attempting to create a directory. // Test the mkdir() function by attempting to create a directory.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment