Skip to content

Commit 6f1cbc4

Browse files
Add tests
1 parent 5e08ad8 commit 6f1cbc4

File tree

4 files changed

+130
-1
lines changed

4 files changed

+130
-1
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Report\Html;
11+
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\Attributes\Small;
14+
use PHPUnit\Framework\TestCase;
15+
16+
#[CoversClass(Colors::class)]
17+
#[Small]
18+
final class ColorsTest extends TestCase
19+
{
20+
public function testCanBeCreatedFromDefaults(): void
21+
{
22+
$colors = Colors::default();
23+
24+
$this->assertSame('#dff0d8', $colors->successLow());
25+
$this->assertSame('#c3e3b5', $colors->successMedium());
26+
$this->assertSame('#99cb84', $colors->successHigh());
27+
$this->assertSame('#fcf8e3', $colors->warning());
28+
$this->assertSame('#f2dede', $colors->danger());
29+
}
30+
31+
public function testCanBeCreatedFromCustomValues(): void
32+
{
33+
$colors = Colors::from('successLow', 'successMedium', 'successHigh', 'warning', 'danger');
34+
35+
$this->assertSame('successLow', $colors->successLow());
36+
$this->assertSame('successMedium', $colors->successMedium());
37+
$this->assertSame('successHigh', $colors->successHigh());
38+
$this->assertSame('warning', $colors->warning());
39+
$this->assertSame('danger', $colors->danger());
40+
}
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Report\Html;
11+
12+
use function realpath;
13+
use PHPUnit\Framework\Attributes\CoversClass;
14+
use PHPUnit\Framework\Attributes\Small;
15+
use PHPUnit\Framework\TestCase;
16+
use SebastianBergmann\CodeCoverage\InvalidArgumentException;
17+
18+
#[CoversClass(CustomCssFile::class)]
19+
#[Small]
20+
final class CustomCssFileTest extends TestCase
21+
{
22+
public function testCanBeCreatedFromDefaults(): void
23+
{
24+
$file = CustomCssFile::default();
25+
26+
$this->assertSame(
27+
realpath(__DIR__ . '/../../../../src/Report/Html/Renderer/Template/css/custom.css'),
28+
$file->path()
29+
);
30+
}
31+
32+
public function testCanBeCreatedFromValidPath(): void
33+
{
34+
$file = CustomCssFile::from(__FILE__);
35+
36+
$this->assertSame(__FILE__, $file->path());
37+
}
38+
39+
public function testCannotBeCreatedFromInvalidPath(): void
40+
{
41+
$this->expectException(InvalidArgumentException::class);
42+
43+
CustomCssFile::from('does-not-exist');
44+
}
45+
}

tests/tests/Report/HtmlTest.php renamed to tests/tests/Report/Html/EndToEndTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use RegexIterator;
1919
use SebastianBergmann\CodeCoverage\TestCase;
2020

21-
final class HtmlTest extends TestCase
21+
final class EndToEndTest extends TestCase
2222
{
2323
private static $TEST_REPORT_PATH_SOURCE;
2424

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Report\Html;
11+
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\Attributes\Small;
14+
use PHPUnit\Framework\TestCase;
15+
use SebastianBergmann\CodeCoverage\InvalidArgumentException;
16+
17+
#[CoversClass(Thresholds::class)]
18+
#[Small]
19+
final class ThresholdsTest extends TestCase
20+
{
21+
public function testCanBeCreatedFromDefaults(): void
22+
{
23+
$thresholds = Thresholds::default();
24+
25+
$this->assertSame(50, $thresholds->lowUpperBound());
26+
$this->assertSame(90, $thresholds->highLowerBound());
27+
}
28+
29+
public function testCanBeCreatedFromValidCustomValues(): void
30+
{
31+
$thresholds = Thresholds::from(60, 95);
32+
33+
$this->assertSame(60, $thresholds->lowUpperBound());
34+
$this->assertSame(95, $thresholds->highLowerBound());
35+
}
36+
37+
public function testCannotBeCreatedFromInvalidValues(): void
38+
{
39+
$this->expectException(InvalidArgumentException::class);
40+
41+
Thresholds::from(90, 50);
42+
}
43+
}

0 commit comments

Comments
 (0)