-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
318 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
include (__DIR__ . "/../functions.php"); | ||
|
||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
$diff = new DiffFileLoader($args->getArg(1)); | ||
$phpcs = new PhpCsLoader($args->getArg(2)); | ||
$coverageCheck = new CoverageCheck($diff, $phpcs, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); | ||
require __DIR__ . '/../src/runners/phpcsDiffFilter.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,3 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
include (__DIR__ . "/../functions.php"); | ||
|
||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
|
||
$diff = new DiffFileLoader(adjustForStdIn($args->getArg(1))); | ||
$phpmd = new PhpMdLoader(adjustForStdIn($args->getArg(2))); | ||
if ($args->getArg("strict")) { | ||
$phpmd = new PhpMdLoaderStrict(adjustForStdIn($args->getArg(2))); | ||
} | ||
|
||
$coverageCheck = new CoverageCheck($diff, $phpmd, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); | ||
require __DIR__ . '/../src/runners/phpmdDiffFilter.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
require_once (__DIR__ . "/../functions.php"); | ||
|
||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
$diff = new DiffFileLoader($args->getArg(1)); | ||
$phpunit = new XMLReport($args->getArg(2)); | ||
$coverageCheck = new CoverageCheck($diff, $phpunit, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); | ||
require __DIR__ . '/../src/runners/phpunitDiffFilter.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
require_once __DIR__ . "/../functions.php"; | ||
global $argv; | ||
|
||
addExceptionHandler(); | ||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
$diff = new DiffFileLoader($args->getArg(1)); | ||
$phpcs = new PhpCsLoader($args->getArg(2)); | ||
$coverageCheck = new CoverageCheck($diff, $phpcs, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
require_once __DIR__ . "/../functions.php"; | ||
global $argv; | ||
|
||
addExceptionHandler(); | ||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
|
||
$diff = new DiffFileLoader(adjustForStdIn($args->getArg(1))); | ||
$phpmd = new PhpMdLoader(adjustForStdIn($args->getArg(2))); | ||
if ($args->getArg("strict")) { | ||
$phpmd = new PhpMdLoaderStrict(adjustForStdIn($args->getArg(2))); | ||
} | ||
|
||
$coverageCheck = new CoverageCheck($diff, $phpmd, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace exussum12\CoverageChecker; | ||
|
||
global $argv; | ||
|
||
require_once __DIR__ . "/../functions.php"; | ||
addExceptionHandler(); | ||
findAutoLoader(); | ||
$args = new ArgParser($argv); | ||
checkCallIsCorrect($args); | ||
$minimumPercentCovered = getMinPercent($args->getArg(3)); | ||
|
||
$matcher = new FileMatchers\EndsWith(); | ||
$diff = new DiffFileLoader($args->getArg(1)); | ||
$phpunit = new XMLReport($args->getArg(2)); | ||
$coverageCheck = new CoverageCheck($diff, $phpunit, $matcher); | ||
|
||
$lines = $coverageCheck->getCoveredLines(); | ||
|
||
handleOutput($lines, $minimumPercentCovered); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace exussum12\CoverageChecker\tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class PhpcsDiffFilterTest extends TestCase | ||
{ | ||
|
||
public function testValid() | ||
{ | ||
$GLOBALS['argv'] = [ | ||
'phpunitDiffFilter', | ||
__DIR__ . '/fixtures/change.txt', | ||
__DIR__ . '/fixtures/phpcs.json' | ||
]; | ||
ob_start(); | ||
require(__DIR__ . "/../src/runners/phpcsDiffFilter.php"); | ||
$output = ob_get_clean(); | ||
$this->assertContains('100.00%', $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
namespace exussum12\CoverageChecker\tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Exception; | ||
|
||
class PhpmdDiffFilterTest extends TestCase | ||
{ | ||
|
||
public function testValid() | ||
{ | ||
$GLOBALS['argv'] = [ | ||
'phpunitDiffFilter', | ||
__DIR__ . '/fixtures/change.txt', | ||
__DIR__ . '/fixtures/phpmd.xml' | ||
]; | ||
ob_start(); | ||
require(__DIR__ . "/../src/runners/phpmdDiffFilter.php"); | ||
$output = ob_get_clean(); | ||
$this->assertContains('100.00%', $output); | ||
} | ||
|
||
public function testNoValidLines() | ||
{ | ||
$GLOBALS['argv'] = [ | ||
'phpunitDiffFilter', | ||
__DIR__ . '/fixtures/change.txt', | ||
__DIR__ . '/fixtures/phpmd-change.xml', | ||
]; | ||
try { | ||
ob_start(); | ||
require(__DIR__ . "/../src/runners/phpmdDiffFilter.php"); | ||
} catch (Exception $e) { | ||
$output = ob_get_clean(); | ||
$this->assertEquals(2, $e->getCode()); | ||
$this->assertContains('0.00%', $output); | ||
return; | ||
} | ||
$this->fail("no exception thrown"); | ||
|
||
} | ||
|
||
public function testNoValidLinesStrict() | ||
{ | ||
$GLOBALS['argv'] = [ | ||
'phpunitDiffFilter', | ||
__DIR__ . '/fixtures/change.txt', | ||
__DIR__ . '/fixtures/phpmd-change.xml', | ||
'--strict', | ||
]; | ||
try { | ||
ob_start(); | ||
require(__DIR__ . "/../src/runners/phpmdDiffFilter.php"); | ||
} catch (Exception $e) { | ||
$output = ob_get_clean(); | ||
$this->assertEquals(2, $e->getCode()); | ||
$this->assertContains('0%', $output); | ||
return; | ||
} | ||
|
||
$this->fail("no exception thrown"); | ||
} | ||
} |
Oops, something went wrong.