diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..095898b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + tools: composer:v2 + + - run: composer update --no-interaction --prefer-dist --no-progress + + - run: vendor/bin/phpunit -c phpunit.xml + + static-analysis: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + coverage: none + tools: composer:v2 + + - run: composer update --no-interaction --prefer-dist --no-progress + + - run: vendor/bin/phpstan analyse + + coverage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + coverage: xdebug + tools: composer:v2 + + - run: composer update --no-interaction --prefer-dist --no-progress + + - run: mkdir -p build/logs + + - run: vendor/bin/phpunit -c phpunit.xml --coverage-clover build/logs/clover.xml + + - uses: codecov/codecov-action@v5 + with: + files: build/logs/clover.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 10ebe43..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ - -language: php - -sudo: false - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -before_script: - - wget https://scrutinizer-ci.com/ocular.phar - - travis_retry composer self-update - - travis_retry composer require satooshi/php-coveralls - - if [ "$(phpenv version-name)" == 7.3 ]; then travis_retry composer require phpstan/phpstan; fi - - travis_retry composer install --no-interaction --prefer-source - - composer dump-autoload -o - -script: - - mkdir -p build/logs - - php vendor/bin/phpunit -c phpunit.xml - - if [ "$(phpenv version-name)" == 7.3 ]; then php vendor/bin/phpstan analyse; fi - -after_script: - - php vendor/bin/coveralls -v - - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml - - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 7dc987d..2aa58ba 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/voku/CssToInlineStyles.svg?branch=master)](https://travis-ci.org/voku/CssToInlineStyles) +[![CI](https://github.com/voku/CssToInlineStyles/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/voku/CssToInlineStyles/actions/workflows/ci.yml) [![codecov.io](http://codecov.io/github/voku/CssToInlineStyles/coverage.svg?branch=master)](http://codecov.io/github/voku/CssToInlineStyles?branch=master) [![Coverage Status](https://coveralls.io/repos/voku/CssToInlineStyles/badge.svg)](https://coveralls.io/r/voku/CssToInlineStyles) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/voku/CssToInlineStyles/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/voku/CssToInlineStyles/?branch=master) @@ -7,7 +7,6 @@ [![Latest Stable Version](https://poser.pugx.org/voku/css-to-inline-styles/v/stable)](https://packagist.org/packages/voku/css-to-inline-styles) [![Total Downloads](https://poser.pugx.org/voku/css-to-inline-styles/downloads)](https://packagist.org/packages/voku/css-to-inline-styles) [![Latest Unstable Version](https://poser.pugx.org/voku/css-to-inline-styles/v/unstable)](https://packagist.org/packages/voku/css-to-inline-styles) -[![PHP 7 ready](http://php7ready.timesplinter.ch/voku/CssToInlineStyles/badge.svg)](https://travis-ci.org/voku/CssToInlineStyles) [![License](https://poser.pugx.org/voku/css-to-inline-styles/license)](https://packagist.org/packages/voku/css-to-inline-styles) # CssToInlineStyles class @@ -74,4 +73,3 @@ $cssToInlineStyles->setCleanup(true); ## Known issues * no support for pseudo selectors - diff --git a/composer.json b/composer.json index 21ff614..e3ba806 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "ext-dom": "*" }, "require-dev": { - "phpunit/phpunit": "~6.0 || ~7.0" + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index d7d3dbb..0e38016 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,15 @@ - - - tests - - - + + + + tests + + + + ./src/ - - - - - + + diff --git a/tests/CssToInlineStylesTest.php b/tests/CssToInlineStylesTest.php index cc9bddb..4c19504 100644 --- a/tests/CssToInlineStylesTest.php +++ b/tests/CssToInlineStylesTest.php @@ -18,12 +18,12 @@ final class CssToInlineStylesTest extends \PHPUnit\Framework\TestCase */ protected $cssToInlineStyles; - protected function setUp() + protected function setUp(): void { $this->cssToInlineStyles = new CssToInlineStyles(); } - protected function teardown() + protected function tearDown(): void { $this->cssToInlineStyles = null; } @@ -521,7 +521,7 @@ public function testXHTMLOutput() $this->cssToInlineStyles->setCSS($css); $actual = $this->cssToInlineStyles->convert(true); - static::assertContains('', $actual); + static::assertStringContainsString('', $actual); } public function testCleanup() @@ -602,14 +602,14 @@ public function testEncodingIso() $this->cssToInlineStyles->setEncoding('ISO-8859-1'); $result = $this->runHTMLToCSS($html, $css, $expected); - static::assertContains('

H', $result); - static::assertContains('Iñtërnâtiônàlizætiøn', $result); + static::assertStringContainsString('

H', $result); + static::assertStringContainsString('Iñtërnâtiônàlizætiøn', $result); } public function testEncodingUtf8() { $testString = \file_get_contents(__DIR__ . '/fixtures/test1Utf8.txt'); - static::assertContains('Iñtërnâtiônàlizætiøn', $testString); + static::assertStringContainsString('Iñtërnâtiônàlizætiøn', $testString); $html = '

' . $testString . '

'; $css = ''; @@ -618,13 +618,13 @@ public function testEncodingUtf8() $this->cssToInlineStyles->setEncoding('UTF-8'); $result = $this->runHTMLToCSS($html, $css, $expected); - static::assertContains('

Hírek', $result); - static::assertContains('Iñtërnâtiônàlizætiøn', $result); + static::assertStringContainsString('

Hírek', $result); + static::assertStringContainsString('Iñtërnâtiônàlizætiøn', $result); } public function testNoHtml() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('No HTML provided.'); $this->cssToInlineStyles->setHTML(''); @@ -640,7 +640,7 @@ public function testXMLHeaderIsRemoved() $this->cssToInlineStyles->setHTML($html); $this->cssToInlineStyles->setCSS(''); - static::assertNotContains('cssToInlineStyles->convert(true)); + static::assertStringNotContainsString('cssToInlineStyles->convert(true)); } public function testXMLHeaderIsRemovedv2()