Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createFile() should create directories. #12826

merged 1 commit into from Dec 17, 2018
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -566,6 +566,12 @@ public function createFile($path, $contents, $forceOverwrite = false)

try {
// Create the directory using the current user permissions.
$directory = dirname($path);
if (!file_exists($directory)) {
mkdir($directory, 0777 ^ umask(), true);

$file = new SplFileObject($path, 'w');
} catch (RuntimeException $e) {
$this->error("Could not write to `{$path}`. Permission denied.", 2);
@@ -580,6 +580,8 @@ public function testErrHelpers($method)
public function testCreateFileSuccess()
$path = TMP . 'shell_test';

@@ -592,6 +594,23 @@ public function testCreateFileSuccess()
$this->assertStringEqualsFile($file, $contents);

public function testCreateFileDirectoryCreation()

$directory = TMP . 'shell_test';
$this->assertFileNotExists($directory, 'Directory should not exist before createFile');

$path = $directory . DS . 'create.txt';
$contents = 'some content';
$result = $this->io->createFile($path, $contents);

$this->assertTrue($result, 'File should create');
$this->assertStringEqualsFile($path, $contents);

* Test that createFile with permissions error.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.