From 5668fc693f0cc484edede1825d23f2b1dce48ef8 Mon Sep 17 00:00:00 2001 From: Grummfy Date: Fri, 5 Feb 2021 15:40:47 +0100 Subject: [PATCH] feat(atoum/reports-extension#51): finalize migration + cleanup --- .github/workflows/linux.yml | 55 +++++++++++++++++++ .php_cs | 1 - .styleci.yml | 17 +++--- .travis.yml | 38 ------------- CHANGELOG.md | 6 ++ classes/coverage/html.php | 10 ++-- classes/model/coverage/klass.php | 8 +-- classes/model/coverage/method.php | 6 +- classes/template.php | 5 +- composer.json | 8 +-- resources/html/templates/class.html.twig | 4 +- resources/html/templates/macros.twig | 4 +- tests/units/classes/coverage/html.php | 6 +- tests/units/classes/extension.php | 16 +++--- tests/units/classes/model/coverage.php | 10 ++-- tests/units/classes/model/coverage/klass.php | 12 ++-- tests/units/classes/model/coverage/method.php | 8 +-- tests/units/classes/sonar/xunit.php | 10 ++-- 18 files changed, 126 insertions(+), 98 deletions(-) create mode 100644 .github/workflows/linux.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..74d08cb --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,55 @@ +name: Linux + +on: + push: + branches: + - master + - 4.x + pull_request: + +jobs: + ubuntu-latest: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: [ '7.2', '7.3' ] + coverage: [ none ] + include: + - php-versions: '7.4' + coverage: xdebug + # see https://github.com/marketplace/actions/setup-php-action#nightly-build-setup + - php-versions: '8.0' + experimental: true + - php-versions: '8.1' + experimental: true + fail-fast: false + + name: PHP ${{ matrix.php-versions }} on ubuntu-latest + + steps: + - name: PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: ${{ matrix.coverage }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php-versions }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Run + run: vendor/bin/atoum --enable-branch-and-path-coverage --test-ext diff --git a/.php_cs b/.php_cs index e3ffa9f..863f845 100644 --- a/.php_cs +++ b/.php_cs @@ -14,7 +14,6 @@ return 'native_function_casing' => true, 'no_blank_lines_after_class_opening' => true, 'no_unused_imports' => true, - 'no_unused_imports' => true, 'no_whitespace_in_blank_line' => true, 'ordered_imports' => true, 'phpdoc_no_access' => true, diff --git a/.styleci.yml b/.styleci.yml index 3c47e41..9f6680e 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,19 +1,21 @@ +risky: true + preset: psr2 enabled: - - blankline_after_open_tag + - alpha_ordered_imports + - blank_line_after_opening_tag + - cast_spaces - concat_with_spaces - - join_function - native_function_casing + - no_alias_functions - no_blank_lines_after_class_opening - - ordered_use + - no_leading_import_slash + - no_unused_imports + - no_whitespace_in_blank_line - phpdoc_no_access - - remove_leading_slash_use - self_accessor - short_array_syntax - - spaces_cast - - unused_use - - whitespacy_lines finder: exclude: @@ -24,4 +26,5 @@ finder: path: - "." not-path: + - "resources/templates" - "resources/html" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b49a160..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 8.0 - - nightly - -cache: - directories: - - vendor - -sudo: false - -env: - matrix: - - COMPOSER_PREFER="--prefer-stable" - - COMPOSER_PREFER="--prefer-lowest" - -matrix: - allow_failures: - - php: nightly - exclude: - - php: 7.0 - env: COMPOSER_PREFER="--prefer-lowest" - - php: 7.1 - env: COMPOSER_PREFER="--prefer-lowest" - - php: 8.0 - env: COMPOSER_PREFER="--prefer-lowest" - - php: nightly - env: COMPOSER_PREFER="--prefer-lowest" - -script: - - composer update $COMPOSER_PREFER - - vendor/bin/atoum --test-ext diff --git a/CHANGELOG.md b/CHANGELOG.md index b3f7c4a..43b54db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 4.0.0 - 2020-02-05 + +* [#53](https://github.com/atoum/reports-extension/pull/53) Compatibility with atoum 4 & PHP 8 ([@franck-paul] & [@Grummfy]) + # 3.0.0 - 2017-10-02 * [#46](https://github.com/atoum/reports-extension/pull/46) Remove the telemetry report ([@jubianchi]) @@ -65,3 +69,5 @@ [@jubianchi]: https://github.com/jubianchi [@ppaulis]: https://github.com/ppaulis [@vonglasow]: https://github.com/vonglasow +[@Grummfy]: https://github.com/Grummfy +[@franck-paul]: https://github.com/franck-paul diff --git a/classes/coverage/html.php b/classes/coverage/html.php index 8a4e628..ef9696b 100644 --- a/classes/coverage/html.php +++ b/classes/coverage/html.php @@ -1,11 +1,11 @@ source = $source; - $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem([__DIR__ . '/../resources/html/templates'])); + $this->twig = new Environment(new FilesystemLoader([__DIR__ . '/../resources/html/templates'])); } public function render(array $model, $destination) diff --git a/composer.json b/composer.json index 72fd751..078ab9d 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ ], "minimum-stability": "beta", "require": { - "php": "^5.4.0 || ^7.0.0 || ^8.0.0", - "twig/twig": "^1.18 | ^2.0", - "symfony/filesystem": "^2.6 | ^3.0 | ^4.0", - "atoum/atoum": "^2.9 || ^3.0 || ^4.0" + "php": "^7.2 || ^8.0.0", + "twig/twig": "^3.0", + "symfony/filesystem": "^5.0", + "atoum/atoum": "^4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2" diff --git a/resources/html/templates/class.html.twig b/resources/html/templates/class.html.twig index 5fbdb0e..58a6cf5 100644 --- a/resources/html/templates/class.html.twig +++ b/resources/html/templates/class.html.twig @@ -21,12 +21,12 @@ {{ number }} -
{{ line.code }}{% spaceless %}
+                        
{{ line.code }}{% apply spaceless %}
                             {% if line.method is not null %}
                                 {{ macros.labelify(methods[line.method].coverage.lines) }}
                                 {{ macros.navigation(class, line.method, methods[line.method].coverage, 'line') }}
                             {% endif %}
-                        {% endspaceless %}
+ {% endapply %}
{% endfor %} diff --git a/resources/html/templates/macros.twig b/resources/html/templates/macros.twig index bea3030..d258400 100644 --- a/resources/html/templates/macros.twig +++ b/resources/html/templates/macros.twig @@ -1,6 +1,6 @@ -{% macro color(value) %}{% spaceless %} +{% macro color(value) %}{% apply spaceless %} {{ value is not null ? (value < 0.3 ? 'danger' : (value < 0.7 ? 'warning' : 'success')) : 'default' }} -{% endspaceless %}{% endmacro %} +{% endapply %}{% endmacro %} {% macro labelify(value) %} {% set class = value is not null ? (value < 0.3 ? 'danger' : (value < 0.7 ? 'warning' : 'success')) : 'default' %} diff --git a/tests/units/classes/coverage/html.php b/tests/units/classes/coverage/html.php index f74dd03..7dcc952 100644 --- a/tests/units/classes/coverage/html.php +++ b/tests/units/classes/coverage/html.php @@ -1,13 +1,13 @@ testedClass->extends('mageekguy\atoum\reports\coverage'); + $this->testedClass->extends('atoum\atoum\reports\coverage'); } } diff --git a/tests/units/classes/extension.php b/tests/units/classes/extension.php index f010fe9..82b752d 100644 --- a/tests/units/classes/extension.php +++ b/tests/units/classes/extension.php @@ -1,9 +1,9 @@ testedClass - ->implements('mageekguy\atoum\extension') + ->implements('atoum\atoum\extension') ; } @@ -19,8 +19,8 @@ public function test__construct() { $this ->if($script = new atoum\scripts\runner(uniqid())) - ->and($script->setArgumentsParser($parser = new \mock\mageekguy\atoum\script\arguments\parser())) - ->and($configurator = new \mock\mageekguy\atoum\configurator($script)) + ->and($script->setArgumentsParser($parser = new \mock\atoum\atoum\script\arguments\parser())) + ->and($configurator = new \mock\atoum\atoum\configurator($script)) ->then ->object($extension = new testedClass()) ->if($this->resetMock($parser)) @@ -35,7 +35,7 @@ public function testGetSetRunner() { $this ->if($this->newTestedInstance) - ->and($runner = new \mock\mageekguy\atoum\runner()) + ->and($runner = new \mock\atoum\atoum\runner()) ->then ->object($this->testedInstance->setRunner($runner))->isTestedInstance ->object($this->testedInstance->getRunner())->isIdenticalTo($runner) @@ -46,7 +46,7 @@ public function testGetSetTest() { $this ->if($this->newTestedInstance) - ->and($test = new \mock\mageekguy\atoum\test()) + ->and($test = new \mock\atoum\atoum\test()) ->then ->object($this->testedInstance->setTest($test))->isTestedInstance ->object($this->testedInstance->getTest())->isIdenticalTo($test) diff --git a/tests/units/classes/model/coverage.php b/tests/units/classes/model/coverage.php index d3012f0..ba8ee6f 100644 --- a/tests/units/classes/model/coverage.php +++ b/tests/units/classes/model/coverage.php @@ -1,14 +1,14 @@ testedClass->extends('mageekguy\atoum\reports\model'); + $this->testedClass->extends('atoum\atoum\reports\model'); } public function testCoverageIs() @@ -16,7 +16,7 @@ public function testCoverageIs() $this ->given( $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()), + $template = new \mock\atoum\atoum\reports\template(uniqid()), $totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX), $totalBranches = rand(1, PHP_INT_MAX), @@ -59,7 +59,7 @@ public function testAddClass() ->given( $name = uniqid(), $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()) + $template = new \mock\atoum\atoum\reports\template(uniqid()) ) ->if($this->newTestedInstance($name)) ->then diff --git a/tests/units/classes/model/coverage/klass.php b/tests/units/classes/model/coverage/klass.php index f985721..4afb66f 100644 --- a/tests/units/classes/model/coverage/klass.php +++ b/tests/units/classes/model/coverage/klass.php @@ -1,14 +1,14 @@ testedClass->extends('mageekguy\atoum\reports\model'); + $this->testedClass->extends('atoum\atoum\reports\model'); } public function testCoverageIs() @@ -17,7 +17,7 @@ public function testCoverageIs() ->given( $class = uniqid(), $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()), + $template = new \mock\atoum\atoum\reports\template(uniqid()), $totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX), $totalBranches = rand(1, PHP_INT_MAX), @@ -63,7 +63,7 @@ public function testAddMethod() $name = uniqid(), $class = uniqid(), $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()) + $template = new \mock\atoum\atoum\reports\template(uniqid()) ) ->if($this->newTestedInstance($class)) ->then @@ -95,7 +95,7 @@ public function testAddLine() $code = uniqid(), $class = uniqid(), $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()) + $template = new \mock\atoum\atoum\reports\template(uniqid()) ) ->if($this->newTestedInstance($class)) ->then diff --git a/tests/units/classes/model/coverage/method.php b/tests/units/classes/model/coverage/method.php index cb0d651..698e4f4 100644 --- a/tests/units/classes/model/coverage/method.php +++ b/tests/units/classes/model/coverage/method.php @@ -1,14 +1,14 @@ testedClass->extends('mageekguy\atoum\reports\model'); + $this->testedClass->extends('atoum\atoum\reports\model'); } public function testCoverageIs() @@ -17,7 +17,7 @@ public function testCoverageIs() ->given( $method = uniqid(), $this->mockGenerator->shuntParentClassCalls(), - $template = new \mock\mageekguy\atoum\reports\template(uniqid()), + $template = new \mock\atoum\atoum\reports\template(uniqid()), $totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX), $totalBranches = rand(1, PHP_INT_MAX), diff --git a/tests/units/classes/sonar/xunit.php b/tests/units/classes/sonar/xunit.php index f03684b..39fe392 100644 --- a/tests/units/classes/sonar/xunit.php +++ b/tests/units/classes/sonar/xunit.php @@ -1,15 +1,15 @@ testedClass->extends('mageekguy\atoum\reports\asynchronous'); + $this->testedClass->extends('atoum\atoum\reports\asynchronous'); } public function testBuild() @@ -24,7 +24,7 @@ public function testBuild() ->and($runner->setScore($score)) ->and($testScore = new atoum\test\score()) ->and($testScore->addPass()) - ->and($test = new \mock\mageekguy\atoum\test()) + ->and($test = new \mock\atoum\atoum\test()) ->and($test->getMockController()->getCurrentMethod[1] = $method = 'method') ->and($test->getMockController()->getCurrentMethod[2] = $otherMethod = 'otherMethod') ->and($test->getMockController()->getCurrentMethod[3] = $thirdMethod = 'thirdMethod')