Skip to content

Commit 4293412

Browse files
authored
Merge pull request #1 from ppavlovic/master
PHP Version constraint 8.2, updated packages, phpunit
2 parents 4c5307d + c33064c commit 4293412

File tree

12 files changed

+80
-60
lines changed

12 files changed

+80
-60
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
composer.lock
3+
tests/unit/.phpunit.result.cache
4+
tests/unit/.phpunit.cache
5+
tests/unit/coverage
6+
vendor/

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@
1414
}
1515
},
1616
"require": {
17-
"g4/value-object" : "*",
18-
"vanilla/garden-cli" : "1.*",
19-
"questocat/console-color" : "1.*"
17+
"php": ">=8.2",
18+
"ext-simplexml": "*",
19+
"g4/value-object": "*",
20+
"vanilla/garden-cli": "4.*",
21+
"questocat/console-color": "1.*"
2022
},
2123
"require-dev": {
22-
"phpunit/phpunit" : "5.*",
24+
"phpunit/phpunit": "10.*",
2325
"squizlabs/php_codesniffer" : "3.*"
2426
},
2527
"scripts": {
2628
"unit-test": [
27-
"./vendor/bin/phpunit -c tests/unit/phpunit.xml --coverage-html tests/unit/coverage"
29+
"XDEBUG_MODE=coverage ./vendor/bin/phpunit -c tests/unit/phpunit.xml --coverage-html tests/unit/coverage"
2830
],
2931
"test-coverage": [
30-
"./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-text"
32+
"XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-text"
3133
],
3234
"test-report": [
33-
"./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-clover=tests/unit/coverage/code-coverage.xml"
35+
"XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always -c tests/unit/phpunit.xml --coverage-clover=tests/unit/coverage/code-coverage.xml"
3436
],
3537
"code-coverage": [
36-
"./bin/code-coverage -p 85 -f tests/unit/coverage/code-coverage.xml"
38+
"XDEBUG_MODE=coverage ./bin/code-coverage -p 85 -f tests/unit/coverage/code-coverage.xml"
3739
],
3840
"psr2": [
3941
"./vendor/bin/phpcs --colors --standard=PSR2 src/"

tests/unit/phpunit.xml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
<phpunit bootstrap="bootstrap.php" colors="true">
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache"
23

3-
<testsuite name="Test Suite">
4-
<directory>./src</directory>
5-
</testsuite>
4+
displayDetailsOnTestsThatTriggerDeprecations="true"
5+
displayDetailsOnTestsThatTriggerErrors="true"
6+
displayDetailsOnTestsThatTriggerNotices="true"
7+
displayDetailsOnTestsThatTriggerWarnings="true"
8+
>
9+
<coverage/>
10+
<testsuite name="Test Suite">
11+
<directory>./src</directory>
12+
</testsuite>
13+
<source>
14+
<include>
15+
<directory suffix=".php">../../src</directory>
16+
</include>
17+
</source>
618

7-
<filter>
8-
<whitelist>
9-
<directory suffix=".php">../../src</directory>
10-
</whitelist>
11-
</filter>
19+
</phpunit>
1220

13-
</phpunit>

tests/unit/src/ConsoleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
use G4\CodeCoverage\Console;
55
use Questocat\ConsoleColor\ConsoleColor;
66

7-
class ConsoleTest extends PHPUnit_Framework_TestCase
7+
class ConsoleTest extends \PHPUnit\Framework\TestCase
88
{
99

1010
public function testConstruct()
1111
{
12+
$this->expectNotToPerformAssertions();
1213
$consoleColorMock = $this->getMockBuilder(ConsoleColor::class)
1314
->disableOriginalConstructor()
1415
->getMock();

tests/unit/src/ExitCodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use G4\CodeCoverage\ExitCode;
55
use G4\CodeCoverage\Exceptions\InvalidExitCodeException;
66

7-
class ExitCodeTest extends PHPUnit_Framework_TestCase
7+
class ExitCodeTest extends \PHPUnit\Framework\TestCase
88
{
99

1010
public function testError()

tests/unit/src/MetricsDataTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
use G4\CodeCoverage\MetricsData;
55
use G4\ValueObject\IntegerNumber;
66

7-
class MetricsDataTest extends PHPUnit_Framework_TestCase
7+
class MetricsDataTest extends \PHPUnit\Framework\TestCase
88
{
99

1010
/**
11-
* @var PHPUnit_Framework_MockObject_MockObject
11+
* @var IntegerNumber&\PHPUnit\Framework\MockObject\MockObject
1212
*/
1313
private $coveredIntegerNumberMock;
1414

1515
/**
16-
* @var PHPUnit_Framework_MockObject_MockObject
16+
* @var IntegerNumber&\PHPUnit\Framework\MockObject\MockObject
1717
*/
1818
private $totalIntegerNumberMock;
1919

@@ -30,7 +30,7 @@ public function testPercentage()
3030
$this->assertEquals(50.0, $this->metricsData->percentage());
3131
}
3232

33-
protected function setUp()
33+
protected function setUp(): void
3434
{
3535
$this->coveredIntegerNumberMock = $this->getMockBuilder(IntegerNumber::class)
3636
->disableOriginalConstructor()
@@ -43,7 +43,7 @@ protected function setUp()
4343
$this->metricsData = new MetricsData($this->totalIntegerNumberMock, $this->coveredIntegerNumberMock);
4444
}
4545

46-
protected function tearDown()
46+
protected function tearDown(): void
4747
{
4848
$this->coveredIntegerNumberMock = null;
4949
$this->totalIntegerNumberMock = null;

tests/unit/src/MetricsFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use G4\CodeCoverage\MetricsFactory;
55
use G4\CodeCoverage\Metrics;
66

7-
class MetricsFactoryTest extends PHPUnit_Framework_TestCase
7+
class MetricsFactoryTest extends \PHPUnit\Framework\TestCase
88
{
99

1010
/**
@@ -18,7 +18,7 @@ class MetricsFactoryTest extends PHPUnit_Framework_TestCase
1818
private $metricsFactory;
1919

2020
/**
21-
* @var PHPUnit_Framework_MockObject_MockObject
21+
* @var IntegerNumber&\PHPUnit\Framework\MockObject\MockObject
2222
*/
2323
private $requiredPercentageMock;
2424

@@ -27,7 +27,7 @@ public function testCreate()
2727
$this->assertInstanceOf(Metrics::class, $this->metricsFactory->create());
2828
}
2929

30-
protected function setUp()
30+
protected function setUp(): void
3131
{
3232
$data = '<?xml version="1.0" encoding="UTF-8"?>
3333
<coverage generated="1508761703">
@@ -44,7 +44,7 @@ protected function setUp()
4444
$this->metricsFactory = new MetricsFactory($this->metricsData, $this->requiredPercentageMock);
4545
}
4646

47-
protected function tearDown()
47+
protected function tearDown(): void
4848
{
4949
$this->requiredPercentageMock = null;
5050
$this->metricsData = null;

tests/unit/src/MetricsFormatterTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use G4\ValueObject\IntegerNumber;
77
use G4\CodeCoverage\MetricsData;
88

9-
class MetricsFormatterTest extends PHPUnit_Framework_TestCase
9+
class MetricsFormatterTest extends \PHPUnit\Framework\TestCase
1010
{
1111

1212
/**
@@ -20,12 +20,12 @@ class MetricsFormatterTest extends PHPUnit_Framework_TestCase
2020
private $metricsFormatter;
2121

2222
/**
23-
* @var PHPUnit_Framework_MockObject_MockObject
23+
* @var MetricsData&\PHPUnit\Framework\MockObject\MockObject
2424
*/
2525
private $metricsDataMock;
2626

2727
/**
28-
* @var PHPUnit_Framework_MockObject_MockObject
28+
* @var IntegerNumber&\PHPUnit\Framework\MockObject\MockObject
2929
*/
3030
private $requiredPercentageMock;
3131

@@ -42,7 +42,7 @@ public function testFormat()
4242
$this->assertEquals(' Elements: 54.00% ', $data[3]);
4343
}
4444

45-
protected function setUp()
45+
protected function setUp(): void
4646
{
4747
$this->requiredPercentageMock = $this->getMockBuilder(IntegerNumber::class)
4848
->disableOriginalConstructor()
@@ -62,7 +62,7 @@ protected function setUp()
6262
$this->metricsFormatter = new MetricsFormatter($this->metrics);
6363
}
6464

65-
protected function tearDown()
65+
protected function tearDown(): void
6666
{
6767
$this->requiredPercentageMock = null;
6868
$this->metricsDataMock = null;

tests/unit/src/MetricsTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
use G4\CodeCoverage\Metrics;
55
use G4\CodeCoverage\MetricsData;
66

7-
class MetricsTest extends PHPUnit_Framework_TestCase
7+
class MetricsTest extends \PHPUnit\Framework\TestCase
88
{
99

1010
/**
11-
* @var PHPUnit_Framework_MockObject_MockObject
11+
* @var MetricsData&\PHPUnit\Framework\MockObject\MockObject
1212
*/
1313
private $elementsMock;
1414

1515
/**
16-
* @var PHPUnit_Framework_MockObject_MockObject
16+
* @var MetricsData&\PHPUnit\Framework\MockObject\MockObject
1717
*/
1818
private $methodsMock;
1919

2020
/**
21-
* @var PHPUnit_Framework_MockObject_MockObject
21+
* @var MetricsData&\PHPUnit\Framework\MockObject\MockObject
2222
*/
2323
private $statementsMock;
2424

@@ -28,7 +28,7 @@ class MetricsTest extends PHPUnit_Framework_TestCase
2828
private $metrics;
2929

3030
/**
31-
* @var PHPUnit_Framework_MockObject_MockObject
31+
* @var IntegerNumber&\PHPUnit\Framework\MockObject\MockObject
3232
*/
3333
private $requiredPercentageMock;
3434

@@ -58,7 +58,7 @@ public function testGetters()
5858
$this->assertInstanceOf(IntegerNumber::class, $this->metrics->getRequiredPercentage());
5959
}
6060

61-
protected function setUp()
61+
protected function setUp(): void
6262
{
6363
$this->elementsMock = $this->getMockBuilder(MetricsData::class)
6464
->disableOriginalConstructor()
@@ -84,7 +84,7 @@ protected function setUp()
8484
);
8585
}
8686

87-
protected function tearDown()
87+
protected function tearDown(): void
8888
{
8989
$this->elementsMock = null;
9090
$this->methodsMock = null;

tests/unit/src/PresenterTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
use G4\CodeCoverage\MetricsFormatter;
88
use G4\ValueObject\StringLiteral;
99

10-
class PresenterTest extends PHPUnit_Framework_TestCase
10+
class PresenterTest extends \PHPUnit\Framework\TestCase
1111
{
1212

1313
/**
14-
* @var PHPUnit_Framework_MockObject_MockObject
14+
* @var Console&\PHPUnit\Framework\MockObject\MockObject
1515
*/
1616
private $consoleMock;
1717

1818
/**
19-
* @var PHPUnit_Framework_MockObject_MockObject
19+
* @var Metrics&\PHPUnit\Framework\MockObject\MockObject
2020
*/
2121
private $metricsMock;
2222

2323
/**
24-
* @var PHPUnit_Framework_MockObject_MockObject
24+
* @var MetricsFormatter&\PHPUnit\Framework\MockObject\MockObject
2525
*/
2626
private $metricsFormatterMock;
2727

@@ -30,6 +30,10 @@ class PresenterTest extends PHPUnit_Framework_TestCase
3030
*/
3131
private $presenter;
3232

33+
/**
34+
* @var (Presenter&\PHPUnit\Framework\MockObject\MockObject)|\PHPUnit\Framework\MockObject\MockObject
35+
*/
36+
private $presenterMock;
3337

3438
public function testMakeMetricsFormatter()
3539
{
@@ -62,7 +66,7 @@ public function testStdOut()
6266
$this->presenterMock->stdOut();
6367
}
6468

65-
protected function setUp()
69+
protected function setUp(): void
6670
{
6771
$this->metricsMock = $this->getMockBuilder(Metrics::class)
6872
->disableOriginalConstructor()
@@ -80,11 +84,11 @@ protected function setUp()
8084

8185
$this->presenterMock = $this->getMockBuilder(Presenter::class)
8286
->setConstructorArgs([$this->metricsMock, $this->consoleMock])
83-
->setMethods(['makeMetricsFormatter'])
87+
->onlyMethods(['makeMetricsFormatter'])
8488
->getMock();
8589
}
8690

87-
protected function tearDown()
91+
protected function tearDown(): void
8892
{
8993
$this->metricsMock = null;
9094
$this->consoleMock = null;

0 commit comments

Comments
 (0)