Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 20 additions & 15 deletions HttpPHPUnit/Main/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ class Main extends Object

/**
* @param string path to PHPUnit
* @param bool $loadPHPUnit
* @throws DirectoryNotFoundException
*/
public function __construct($phpUnitDir = NULL)
public function __construct($phpUnitDir = NULL, $loadPHPUnit = true)
{
if (!$phpUnitDir) $phpUnitDir = __DIR__ . '/../../PHPUnit';
if (!is_dir($phpUnitDir)) throw new DirectoryNotFoundException($phpUnitDir);
set_include_path($phpUnitDir);
require_once 'PHPUnit/Autoload.php';
if ($loadPHPUnit)
{
if (!$phpUnitDir) $phpUnitDir = __DIR__ . '/../../PHPUnit';
if (!is_dir($phpUnitDir)) throw new DirectoryNotFoundException($phpUnitDir);
set_include_path($phpUnitDir);
require_once 'PHPUnit/Autoload.php';
}
require_once __DIR__ . '/Command.php';
require_once __DIR__ . '/TemplateFactory.php';
require_once __DIR__ . '/../ResultPrinter/ResultPrinter.php';
Expand Down Expand Up @@ -131,20 +135,21 @@ public function run($dir, $arg = '--no-globals-backup --strict')
* @param string app dir
* @param string report dir
* @throws DirectoryNotFoundException
* @return PHP_CodeCoverage
* @return PHP_CodeCoverage|NULL
*/
public function coverage($appDir, $coverageDir)
{
require_once 'PHP/CodeCoverage.php';
$coverage = PHP_CodeCoverage::getInstance();
if (!$this->run OR $this->testDir OR !extension_loaded('xdebug'))
if (!extension_loaded('xdebug'))
{
$this->onAfter['coverage'] = function () {
echo 'Coverage: The Xdebug extension is not loaded.';
};
return;
}
$coverage = new PHP_CodeCoverage;
$coverage->setProcessUncoveredFilesFromWhitelist(true);
if (!$this->run OR $this->testDir)
{
if (!extension_loaded('xdebug'))
{
$this->onAfter['coverage'] = function () {
echo 'Coverage: The Xdebug extension is not loaded.';
};
}
return $coverage;
}
@mkdir ($coverageDir);
Expand Down
6 changes: 6 additions & 0 deletions HttpPHPUnit/Main/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
*/
class TemplateFactory extends Control
{

public function templatePrepareFilters($template)
{
$template->registerFilter(new \Nette\Latte\Engine);
}

public static function create($file)
{
$control = new self;
Expand Down
4 changes: 4 additions & 0 deletions HttpPHPUnit/ResultPrinter/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ protected function renderError(PHPUnit_Framework_Test $test, Exception $e, $stat
$this->write('</h3>');

$message = $e->getMessage();
if ($e instanceof \PHPUnit_Framework_ExpectationFailedException && $comparison = $e->getComparisonFailure())
{
$message .= "\n \n" . $comparison->toString();
}
if (!$message) $message = '(no message)';
if ($state === self::ERROR) $message = get_class($e) . ': ' . $message;
if (strlen($message) > 400 OR substr_count($message, "\n") > 4)
Expand Down
5 changes: 5 additions & 0 deletions HttpPHPUnit/StructureRenderer/StructureRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,9 @@ private function loadMethod($path)
return $result;
}

public function templatePrepareFilters($template)
{
$template->registerFilter(new \Nette\Latte\Engine);
}

}
Loading