Skip to content

Commit 4ebadcd

Browse files
committed
Add interface to specify custom.css file for HTML report
Related to sebastianbergmann#556. It would help to make the custom CSS feature more accessible by making the file a configuration option, e.g. in phpunit: <coverage> <report> <html customCssFile="path/to/custom.css" /> </report> </coverage> The `$customCssFile` argument is added to the Html\Facade interface as a prerequisite to any changes to phpunit configuration options. If not null, it copies this file to the custom.css destination instead of the empty custom.css stub file.
1 parent 75a0f91 commit 4ebadcd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Report/Html/Facade.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ final class Facade
4141
*/
4242
private $highLowerBound;
4343

44-
public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, string $generator = '')
44+
/**
45+
* @var ?string
46+
*/
47+
private $customCssFile;
48+
49+
public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, string $generator = '', ?string $customCssFile = null)
4550
{
4651
if ($lowUpperBound > $highLowerBound) {
4752
throw new InvalidArgumentException(
@@ -52,6 +57,7 @@ public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, s
5257
$this->generator = $generator;
5358
$this->highLowerBound = $highLowerBound;
5459
$this->lowUpperBound = $lowUpperBound;
60+
$this->customCssFile = $customCssFile;
5561
$this->templatePath = __DIR__ . '/Renderer/Template/';
5662
}
5763

@@ -118,7 +124,7 @@ private function copyFiles(string $target): void
118124
copy($this->templatePath . 'css/bootstrap.min.css', $dir . 'bootstrap.min.css');
119125
copy($this->templatePath . 'css/nv.d3.min.css', $dir . 'nv.d3.min.css');
120126
copy($this->templatePath . 'css/style.css', $dir . 'style.css');
121-
copy($this->templatePath . 'css/custom.css', $dir . 'custom.css');
127+
copy($this->customCssFile ?? $this->templatePath . 'css/custom.css', $dir . 'custom.css');
122128
copy($this->templatePath . 'css/octicons.css', $dir . 'octicons.css');
123129

124130
$dir = $this->directory($target . '_icons');

0 commit comments

Comments
 (0)