Skip to content

Commit 8c69cbb

Browse files
authored
Add 7.4 support (#62)
* Add 7.4 support Wider range of unit tests and fixing depricated stuff * Fix phpunit compatibility * Missed the shim from the commit * Clean up
1 parent 4614727 commit 8c69cbb

26 files changed

+124
-69
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ matrix:
1111
- php: 7.2
1212
env: UPDATE_COVERAGE=1
1313
- php: 7.3
14+
- php: 7.4
1415
fast_finish: true
1516
before_script:
1617
- composer global require squizlabs/php_codesniffer

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "exussum12/coverage-checker",
33
"description": "Allows checking the code coverage of a single pull request",
44
"require-dev": {
5-
"phpunit/phpunit": "^6.5"
5+
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0"
66
},
77
"license": "MIT",
88
"authors": [

phpunit.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
beStrictAboutTestsThatDoNotTestAnything="true"
99
beStrictAboutTodoAnnotatedTests="true"
1010
verbose="true">
11-
<testsuite>
11+
<testsuite name="coverageChecker">
1212
<directory suffix="Test.php">tests</directory>
1313
</testsuite>
1414

@@ -21,8 +21,8 @@
2121
<log
2222
type="coverage-html"
2323
target="report"
24-
lowUpperBound="35"
25-
highLowerBound="70"/>
24+
lowUpperBound="90"
25+
highLowerBound="95"/>
2626
<log type="coverage-clover" target="report/coverage.xml"/>
2727
</logging>
2828
</phpunit>

tests/ArgParserTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ class ArgParserTest extends TestCase
99
{
1010
protected $parser;
1111

12-
public function setUp()
12+
/**
13+
* @before
14+
*/
15+
public function setUpTest()
1316
{
1417
$args = [
1518
'file.php',
@@ -20,6 +23,7 @@ public function setUp()
2023
];
2124
$this->parser = new ArgParser($args);
2225
}
26+
2327
public function testNumericArgs()
2428
{
2529
$this->assertSame("file", $this->parser->getArg(1));

tests/GenericDiffFilterTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
class GenericDiffFilterTest extends TestCase
1212
{
13+
use TestShim;
1314

1415
public function testValid()
1516
{
@@ -20,9 +21,9 @@ public function testValid()
2021
__DIR__ . '/fixtures/phpcs.json'
2122
];
2223
ob_start();
23-
require(__DIR__ . "/../src/Runners/generic.php");
24+
require(__DIR__ . '/../src/Runners/generic.php');
2425
$output = ob_get_clean();
25-
$this->assertContains('100.00%', $output);
26+
$this->assertContainsString('100.00%', $output);
2627
}
2728

2829
public function testMissingHandler()
@@ -34,10 +35,10 @@ public function testMissingHandler()
3435
];
3536
try {
3637
ob_start();
37-
require(__DIR__ . "/../src/Runners/generic.php");
38+
require(__DIR__ . '/../src/Runners/generic.php');
3839
} catch (Exception $exception) {
3940
$output = ob_get_clean();
40-
$this->assertContains('--phpcs', $output);
41+
$this->assertContainsString('--phpcs', $output);
4142
return true;
4243
}
4344

tests/Loaders/CheckstyleTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ class CheckstyleTest extends PhanTextTest
88
/** @var Checkstyle */
99
protected $phan;
1010
protected $prefix = '';
11-
protected function setUp()
11+
12+
/**
13+
* @before
14+
*/
15+
protected function setUpTest()
1216
{
13-
parent::setUp();
1417
$this->phan = new Checkstyle(__DIR__ . '/../fixtures/checkstyle.xml');
1518
}
1619
}

tests/Loaders/CodeClimateTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ class CodeClimateTest extends PhanTextTest
88
/** @var CodeClimate */
99
protected $phan;
1010
protected $prefix = '';
11-
protected function setUp()
11+
12+
/**
13+
* @before
14+
*/
15+
protected function setUpTest()
1216
{
13-
parent::setUp();
1417
$this->phan = new CodeClimate(__DIR__ . '/../fixtures/codeclimate.json');
1518
}
1619
}

tests/Loaders/HumbugLoaderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
use InvalidArgumentException;
55
use PHPUnit\Framework\TestCase;
66
use exussum12\CoverageChecker\Loaders\Humbug;
7+
use exussum12\CoverageChecker\tests\TestShim;
78

89
class HumbugLoaderTest extends TestCase
910
{
11+
use TestShim;
12+
1013
public function testCanMakeClass()
1114
{
1215
$humbug = new Humbug(__DIR__ . '/../fixtures/humbug.json');
@@ -15,7 +18,7 @@ public function testCanMakeClass()
1518
$this->assertEquals(1, count($invalidFiles));
1619
$file = 'src/DiffLineHandle/OldVersion/DiffStart.php';
1720

18-
$this->assertContains(
21+
$this->assertContainsString(
1922
'Failed on escaped check',
2023
current($humbug->getErrorsOnLine($file, 23))
2124
);

tests/Loaders/LoadPhpcsReportTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ public function testCanMakeClass()
2323
);
2424
}
2525

26-
/**
27-
* @expectedException InvalidArgumentException
28-
*/
2926
public function testRejectsInvalidData()
3027
{
3128
$this->expectException(InvalidArgumentException::class);

tests/Loaders/PhanJsonTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ class PhanJsonTest extends PhanTextTest
77
{
88
/** @var PhanJsonTest */
99
protected $phan;
10-
protected function setUp()
10+
11+
/**
12+
* @before
13+
*/
14+
protected function setUpTest()
1115
{
12-
parent::setUp();
1316
$this->phan = new PhanJson(__DIR__ . '/../fixtures/phan.json');
1417
}
1518
}

tests/Loaders/PhanTextTest.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33

44
use PHPUnit\Framework\TestCase;
55
use exussum12\CoverageChecker\Loaders\PhanText;
6+
use exussum12\CoverageChecker\tests\TestShim;
67

78
class PhanTextTest extends TestCase
89
{
10+
use TestShim;
911
/** @var PhanText */
1012
protected $phan;
11-
protected function setUp()
13+
14+
/**
15+
* @before
16+
*/
17+
protected function setUpTest()
1218
{
13-
parent::setUp();
1419
$this->phan = new PhanText(__DIR__ . '/../fixtures/phan.txt');
1520
}
1621

@@ -22,7 +27,7 @@ public function testOutput()
2227

2328
$this->assertCount(2, $lines);
2429

25-
$this->assertContains(
30+
$this->assertContainsString(
2631
'Argument 1 (string) is int but \strlen() takes string',
2732
current($this->phan->getErrorsOnLine($file1, 35))
2833
);

tests/Loaders/PhpMndTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class PhpMndTest extends TestCase
88
{
99
private $mnd;
1010

11-
public function setUp()
11+
/**
12+
* @before
13+
*/
14+
public function setUpTest()
1215
{
1316
$file = __DIR__ . '/../fixtures/phpmnd.txt';
1417
$this->mnd = new PhpMnd($file);

tests/Loaders/PhpStanTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ class PhpStanTest extends TestCase
99
/** @var PhpStan */
1010
protected $stan;
1111

12-
public function setUp()
12+
/**
13+
* @before
14+
*/
15+
public function setUpTest()
1316
{
1417
$file = __DIR__ . '/../fixtures/phpstan.txt';
1518
$this->stan = new PhpStan($file);

tests/Loaders/PhpcpdTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ class PhpcpdTest extends TestCase
88
{
99
/** @var Phpcpd */
1010
protected $cpd;
11-
protected function setUp()
11+
12+
/**
13+
* @before
14+
*/
15+
protected function setUpTest()
1216
{
13-
parent::setUp();
1417
$this->cpd = new Phpcpd(__DIR__ . '/../fixtures/phpcpd.txt');
1518

1619
$this->cpd->parseLines();

tests/Loaders/PhpmndXmlDiffFilterTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class PhpmndXmlDiffFilterTest extends TestCase
99
/** @var PhpMndXmlLoader */
1010
private $mnd;
1111

12-
public function setUp()
12+
/**
13+
* @before
14+
*/
15+
public function setupTest()
1316
{
14-
parent::setUp();
1517
$file = __DIR__ . "/../fixtures/phpmnd.xml";
1618
$this->mnd = new PhpMndXml($file);
1719
}

tests/Loaders/PylintTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ class PylintTest extends PhanTextTest
77
{
88
/** @var Pylint */
99
protected $phan;
10-
protected function setUp()
10+
11+
/**
12+
* @before
13+
*/
14+
protected function setUpTest()
1115
{
12-
parent::setUp();
1316
$this->phan = new Pylint(__DIR__ . '/../fixtures/pylint.txt');
1417
}
1518
}

tests/PhpCsReflectionTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
class PhpCsReflectionTest extends TestCase
1212
{
13+
use TestShim;
1314
public function testRelatedMethods()
1415
{
1516
$GLOBALS['argv'] = [
@@ -54,10 +55,10 @@ public function testRelatedMethodsFileNotFound()
5455

5556
try {
5657
ob_start();
57-
require(__DIR__ . "/../src/Runners/generic.php");
58+
require(__DIR__ . '/../src/Runners/generic.php');
5859
} catch (Exception $exception) {
5960
$output = ob_get_clean();
60-
$this->assertContains("Can't find file", $output);
61+
$this->assertContainsString("Can't find file", $output);
6162

6263
return true;
6364
}

tests/PhpStanRelatedTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
class PhpStanRelatedTest extends TestCase
1212
{
13+
use TestShim;
1314
public function testRelatedMethodsWithoutAutoload()
1415
{
1516
$GLOBALS['argv'] = [
@@ -20,9 +21,9 @@ public function testRelatedMethodsWithoutAutoload()
2021
];
2122

2223
ob_start();
23-
require(__DIR__ . "/../src/Runners/generic.php");
24+
require(__DIR__ . '/../src/Runners/generic.php');
2425
$output = ob_get_clean();
25-
$this->assertContains('100.00%', $output);
26+
$this->assertContainsString('100.00%', $output);
2627
}
2728

2829
public function testRelatedMethods()
@@ -40,7 +41,7 @@ public function testRelatedMethods()
4041
require(__DIR__ . "/../src/Runners/generic.php");
4142
} catch (Exception $exception) {
4243
$output = ob_get_clean();
43-
$this->assertContains('used test.php', $output);
44+
$this->assertContainsString('used test.php', $output);
4445
return true;
4546
}
4647

tests/PhpcsDiffFilterTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
class PhpcsDiffFilterTest extends TestCase
1111
{
12+
use TestShim;
1213

1314
public function testValid()
1415
{
@@ -19,9 +20,9 @@ public function testValid()
1920
__DIR__ . '/fixtures/phpcs.json'
2021
];
2122
ob_start();
22-
require(__DIR__ . "/../src/Runners/generic.php");
23+
require(__DIR__ . '/../src/Runners/generic.php');
2324
$output = ob_get_clean();
24-
$this->assertContains('100.00%', $output);
25+
$this->assertContainsString('100.00%', $output);
2526
}
2627

2728
public function testStrictMode()
@@ -33,8 +34,8 @@ public function testStrictMode()
3334
__DIR__ . '/fixtures/phpcsstrict.json'
3435
];
3536
ob_start();
36-
require(__DIR__ . "/../src/Runners/generic.php");
37+
require(__DIR__ . '/../src/Runners/generic.php');
3738
$output = ob_get_clean();
38-
$this->assertContains('100.00%', $output);
39+
$this->assertContainsString('100.00%', $output);
3940
}
4041
}

tests/PhpmdDiffFilterTest.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class PhpmdDiffFilterTest extends TestCase
1212
{
1313

14+
use TestShim;
1415
public function testValid()
1516
{
1617
$GLOBALS['argv'] = [
@@ -23,8 +24,8 @@ public function testValid()
2324
ob_start();
2425
require(__DIR__ . "/../src/Runners/generic.php");
2526
$output = ob_get_clean();
26-
$this->assertContains('100.00', $output);
27-
$this->assertContains('Passed', $output);
27+
$this->assertContainsString('100.00', $output);
28+
$this->assertContainsString('Passed', $output);
2829
}
2930

3031
public function testNoValidLines()
@@ -37,11 +38,11 @@ public function testNoValidLines()
3738
];
3839
try {
3940
ob_start();
40-
require(__DIR__ . "/../src/Runners/generic.php");
41+
require(__DIR__ . '/../src/Runners/generic.php');
4142
} catch (Exception $e) {
4243
$output = ob_get_clean();
4344
$this->assertEquals(2, $e->getCode());
44-
$this->assertContains('0.00%', $output);
45+
$this->assertContainsString('0.00%', $output);
4546
return;
4647
}
4748
$this->fail("no exception thrown");
@@ -61,10 +62,10 @@ public function testNoValidLinesStrict()
6162
} catch (Exception $e) {
6263
$output = ob_get_clean();
6364
$this->assertEquals(2, $e->getCode());
64-
$this->assertContains('0%', $output);
65+
$this->assertContainsString('0%', $output);
6566
return;
6667
}
6768

68-
$this->fail("no exception thrown");
69+
$this->fail('no exception thrown');
6970
}
7071
}

0 commit comments

Comments
 (0)