Skip to content

Commit

Permalink
repairs code coverage logic
Browse files Browse the repository at this point in the history
github action for coverage

github action for coverage
  • Loading branch information
ffflabs committed Apr 27, 2021
1 parent e62abad commit 1563b54
Show file tree
Hide file tree
Showing 30 changed files with 172 additions and 132 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: coverage

on: ['pull_request']

jobs:
coverage:
runs-on: 'ubuntu-latest'
strategy:
matrix:
php: ['7.4']

name: PHP ${{ matrix.php }} - 'ubuntu-latest' - 'prefer-stable'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
extensions:
gd
pcov
coverage: pcov

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
path: "~/.composer/cache"
key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php-version }}-composer-
- name: Setup Problem Matches
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install PHP dependencies
run: composer update --'prefer-stable' --no-interaction --no-progress

- name: Coverage
run: composer coverage
if: "matrix.php == 7.4"
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: composer:v2
extensions: gd
extensions: gd, pcov
coverage: none

- name: Setup Problem Matches
Expand All @@ -31,4 +31,4 @@ jobs:
run: composer update --'prefer-stable' --no-interaction --no-progress

- name: Unit Tests
run: composer test
run: composer test
13 changes: 8 additions & 5 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ build:
analysis:
tests:
override:
-
command: phpcs-run
use_website_config: false
- phpcs-run

-
command: composer coverage
coverage:
file: 'tests/_output/coverage.xml'
format: 'clover'
- php-scrutinizer-run



tools:
php_code_coverage: false
php_code_coverage: true

filter:
excluded_paths:
- 'Examples/'
- 'tests/'
dependency_paths:
- 'vendor/'
- 'vendor/'
4 changes: 2 additions & 2 deletions Examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
max-height: 100vh;
overflow-y: auto;
border-right: 1px solid #AAA;
width: 300px;
float-left;
width: 350px;
float:left;
padding-left: 0;
padding-right: 0;
}
Expand Down
56 changes: 25 additions & 31 deletions Examples/show-example.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
<?php
if (!isset($_GET['target'])) {
$_GET['target'] = 'axislabelbkgex01.php';
}
if (!isset($_GET['folder'])) {
$_GET['folder'] = 'examples_axis';
}

$target = basename(urldecode($_GET['target']));
$folder = basename(urldecode($_GET['folder']));
$target = basename(urldecode($_GET['target'] ?? 'axislabelbkgex01.php'));
$folder = basename(urldecode($_GET['folder'] ?? 'examples_axis'));

echo "<html>";
echo '<head>';
echo '<title> Image ' . $target . '</title>';

?>
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<title> Test suite for JpGraph - <?php echo $target; ?></title>
<script type="text/javascript" language="javascript">
<!--
function resize()
{
return true;
}
//-->
</script>
</head>

<?php
if (!strstr($target, 'csim')) {
echo '<frameset rows="*,*" onLoad="resize()">';
echo '<frame src="show-image.php?' . 'folder=' . ($folder) . '&target=' . ($target) . '" name="image">';
echo '<frame src="show-source.php?folder=' . ($folder) . '&target=' . ($target) . '" name="source">';
$highlighted = highlight_file(($folder ? $folder . '/' : '') . $target, true);

echo '</head>';
echo '<body>';
echo '<div style="float:right;"><img src="' . ($folder ? $folder . '/' : '') . ($target) . '" border=0 alt="' . $target . '" align="left"></div>';
echo $highlighted;
echo '</body>';
} else {

echo '<script type="text/javascript" language="javascript">';
echo '<!--';
echo 'function resize() {';
echo 'return true;';
echo '}';
echo '//';
echo '-->';
echo '</script>';
echo '</head>';
echo '<frameset rows="*" onLoad="resize()">';
echo '<frame src="' . ($folder) . '/' . ($target) . '" name="image">';
echo '</frameset>';
}
?>


</frameset>
</html>
echo '</html>';
20 changes: 0 additions & 20 deletions Examples/show-image.php

This file was deleted.

16 changes: 0 additions & 16 deletions Examples/show-source.php

This file was deleted.

6 changes: 3 additions & 3 deletions Examples/testsuit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

require __DIR__ . '/../vendor/autoload.php';
/**
* JPGraph v4.0.3
*/
Expand All @@ -26,11 +26,11 @@ class TestDriver
private $iDir;
private $exampleDir;

public function __construct($aType = 1, $folder = 'examples_axis', $aDir = '')
public function __construct($aType = 1, $folder = 'examples_axis', $aDir = __DIR__)
{
$this->iType = $aType;
if ($aDir == '') {
$aDir = getcwd();
$aDir = __DIR__;
}
if (!chdir($aDir)) {
die("PANIC: Can't access directory : ${aDir}");
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"fix": "vendor/bin/phpcbf --standard=.phpcs.xml src/* tests/* && vendor/bin/php-cs-fixer fix --config=.php_cs.php",
"lint": "vendor/bin/phplint",
"start": "php -S localhost:8000 -t Examples",
"test": "php vendor/bin/codecept run unit "
"test": "php vendor/bin/codecept run unit ",
"coverage": "XDEBUG_MODE=coverage php vendor/bin/codecept run unit --coverage --coverage-xml"
},
"support": {
"issues": "https://github.com/huasofoundries/jpgraph/issues"
Expand Down
2 changes: 1 addition & 1 deletion tests/AxisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class AxisTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/BackgroundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class BackgroundTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/BarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class BarTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CanvasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class CanvasTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ContourTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class ContourTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class DateTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/GanttTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class GanttTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class GeneralTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ImgTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class ImgTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/LineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class LineTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/PieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class PieTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/RotateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class RotateTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ScatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class ScatterTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/StaticbandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class StaticbandTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class ThemeTest extends \Codeception\Test\Unit
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TickTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group ready
*
* @internal
* @coversNothing
*
*/
class TickTest extends \Codeception\Test\Unit
{
Expand Down
Loading

0 comments on commit 1563b54

Please sign in to comment.