Skip to content

Commit

Permalink
Closes #3410
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 18, 2018
1 parent c0869f7 commit 4dec3dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog-7.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes of the PHPUnit 7.4 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [7.4.5] - 2018-MM-DD

* Fixed [#3410](https://github.com/sebastianbergmann/phpunit/issues/3410): Parent directory of `cacheResultFile` is not created when it does not exist

## [7.4.4] - 2018-11-14

### Fixed
Expand Down Expand Up @@ -41,6 +45,7 @@ All notable changes of the PHPUnit 7.4 release series are documented in this fil
* Implemented [#3284](https://github.com/sebastianbergmann/phpunit/issues/3284): Ability to reorder tests based on execution time
* Implemented [#3290](https://github.com/sebastianbergmann/phpunit/issues/3290): Ability to load a PHP script before any code of PHPUnit itself is loaded

[7.4.5]: https://github.com/sebastianbergmann/phpunit/compare/7.4.4...7.4.5
[7.4.4]: https://github.com/sebastianbergmann/phpunit/compare/7.4.3...7.4.4
[7.4.3]: https://github.com/sebastianbergmann/phpunit/compare/7.4.2...7.4.3
[7.4.2]: https://github.com/sebastianbergmann/phpunit/compare/7.4.1...7.4.2
Expand Down
14 changes: 14 additions & 0 deletions src/Util/TestResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ public function saveToFile(): void
return;
}

if (!$this->createDirectory(\dirname($this->cacheFilename))) {
throw new Exception(
\sprintf(
'Cannot create directory "%s" for result cache file',
$this->cacheFilename
)
);
}

\file_put_contents(
$this->cacheFilename,
\serialize($this)
Expand Down Expand Up @@ -176,4 +185,9 @@ public function unserialize($serialized): void
}
}
}

private function createDirectory(string $directory): bool
{
return !(!\is_dir($directory) && !@\mkdir($directory, 0777, true) && !\is_dir($directory));
}
}

1 comment on commit 4dec3dd

@localheinz
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @sebastianbergmann!

Please sign in to comment.