diff --git a/PHP/CodeCoverage/Report/HTML.php b/PHP/CodeCoverage/Report/HTML.php index b8a9ceb41..dd1caf212 100644 --- a/PHP/CodeCoverage/Report/HTML.php +++ b/PHP/CodeCoverage/Report/HTML.php @@ -129,7 +129,7 @@ public function __construct($title = '', $charset = 'UTF-8', $yui = TRUE, $highl */ public function process(PHP_CodeCoverage $coverage, $target) { - $target = PHP_CodeCoverage_Util::getDirectory($target); + $target = $this->getDirectory($target); $report = $coverage->getReport(); unset($coverage); @@ -210,4 +210,32 @@ protected function copyFiles($target) copy($this->templatePath . $file, $target . $file); } } + + /** + * @param string $directory + * @return string + * @throws PHP_CodeCoverage_Exception + * @since Method available since Release 1.2.0 + */ + protected function getDirectory($directory) + { + if (substr($directory, -1, 1) != DIRECTORY_SEPARATOR) { + $directory .= DIRECTORY_SEPARATOR; + } + + if (is_dir($directory)) { + return $directory; + } + + if (mkdir($directory, 0777, TRUE)) { + return $directory; + } + + throw new PHP_CodeCoverage_Exception( + sprintf( + 'Directory "%s" does not exist.', + $directory + ) + ); + } } diff --git a/PHP/CodeCoverage/Util.php b/PHP/CodeCoverage/Util.php index b0233c362..02564a130 100644 --- a/PHP/CodeCoverage/Util.php +++ b/PHP/CodeCoverage/Util.php @@ -98,33 +98,6 @@ class PHP_CodeCoverage_Util */ protected static $ids = array(); - /** - * @param string $directory - * @return string - * @throws PHP_CodeCoverage_Exception - */ - public static function getDirectory($directory) - { - if (substr($directory, -1, 1) != DIRECTORY_SEPARATOR) { - $directory .= DIRECTORY_SEPARATOR; - } - - if (is_dir($directory)) { - return $directory; - } - - if (mkdir($directory, 0777, TRUE)) { - return $directory; - } - - throw new PHP_CodeCoverage_Exception( - sprintf( - 'Directory "%s" does not exist.', - $directory - ) - ); - } - /** * Returns the files and lines a test method wants to cover. * diff --git a/Tests/PHP/CodeCoverage/UtilTest.php b/Tests/PHP/CodeCoverage/UtilTest.php index e9a336562..026fda466 100644 --- a/Tests/PHP/CodeCoverage/UtilTest.php +++ b/Tests/PHP/CodeCoverage/UtilTest.php @@ -44,10 +44,6 @@ * @since File available since Release 1.0.0 */ -if (stream_resolve_include_path('vfsStream/vfsStream.php')) { - require_once 'vfsStream/vfsStream.php'; -} - if (!defined('TEST_FILES_PATH')) { define( 'TEST_FILES_PATH', @@ -99,15 +95,6 @@ */ class PHP_CodeCoverage_UtilTest extends PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('vfsStream')) { - $this->markTestSkipped('vfsStream is not available.'); - } - - vfsStream::setup('UtilTest'); - } - /** * @covers PHP_CodeCoverage_Util::getLinesToBeCovered * @covers PHP_CodeCoverage_Util::resolveCoversToReflectionObjects @@ -248,52 +235,6 @@ public function testGetLinesToBeIgnored2() ); } - /** - * @covers PHP_CodeCoverage_Util::getDirectory - */ - public function testGetDirectory() - { - if (!class_exists('vfsStream')) { - $this->markTestSkipped('vfsStream is not installed'); - } - - $this->assertEquals( - vfsStream::url('UtilTest') . '/', - PHP_CodeCoverage_Util::getDirectory(vfsStream::url('UtilTest')) - ); - } - - /** - * @covers PHP_CodeCoverage_Util::getDirectory - */ - public function testGetDirectory2() - { - if (!class_exists('vfsStream')) { - $this->markTestSkipped('vfsStream is not installed'); - } - - PHP_CodeCoverage_Util::getDirectory( - vfsStream::url('UtilTest') . '/report' - ); - - $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('report')); - } - - /** - * @covers PHP_CodeCoverage_Util::getDirectory - * @expectedException PHP_CodeCoverage_Exception - */ - public function testGetDirectory3() - { - if (!class_exists('vfsStream')) { - $this->markTestSkipped('vfsStream is not installed'); - } - - PHP_CodeCoverage_Util::getDirectory( - vfsStream::url('/not/existing/path') - ); - } - /** * @covers PHP_CodeCoverage_Util::percent */