diff --git a/.travis.yml b/.travis.yml index d61dc1d..f9ad71d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,24 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - - hhvm-nightly + - 7.0 + - 7.1 + - 7.2 + - 7.3 + env: + - XDEBUG_MODE=coverage + - 7.4 + env: + - XDEBUG_MODE=coverage + - 8.0 + env: + - XDEBUG_MODE=coverage before_script: - composer install --dev -script: phpunit --coverage-clover=coverage.clover +script: composer test -- --coverage-clover=coverage.clover after_script: - wget https://scrutinizer-ci.com/ocular.phar diff --git a/composer.json b/composer.json index ff11d45..f4baed1 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,10 @@ } ], "require": { - "php": ">=5.4.0" + "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "symfony/phpunit-bridge": "^5.2" }, "suggest": { "ext-mbstring": "For using the MbTranscoder", @@ -33,5 +33,8 @@ "branch-alias": { "dev-master": "1.0.x-dev" } + }, + "scripts": { + "test": "vendor/bin/simple-phpunit" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cd050a6..65987cf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ convertErrorsToExceptions="false" > - + ./tests/ diff --git a/tests/IconvTranscoderTest.php b/tests/IconvTranscoderTest.php index 61b9855..fbd14d6 100644 --- a/tests/IconvTranscoderTest.php +++ b/tests/IconvTranscoderTest.php @@ -4,24 +4,29 @@ use Ddeboer\Transcoder\IconvTranscoder; -class IconvTranscoderTest extends \PHPUnit_Framework_TestCase +class IconvTranscoderTest extends \PHPUnit\Framework\TestCase { /** * @var IconvTranscoder */ private $transcoder; - protected function setUp() + /** + * @before + */ + protected function doSetUp() { $this->transcoder = new IconvTranscoder(); + // Passing null (empty encoding name) to iconv makes it detect encoding from locale. + // The phpunit-bridge sets locale to C for consistency but that implies ASCII. + // This file uses UTF-8 so we have to set the locale accordingly. + $this->setLocale(\LC_ALL, 'C.UTF-8'); } - /** - * @expectedException \Ddeboer\Transcoder\Exception\UnsupportedEncodingException - * @expectedExceptionMessage bad-encoding - */ public function testTranscodeUnsupportedFromEncoding() { + $this->expectException(\Ddeboer\Transcoder\Exception\UnsupportedEncodingException::class); + $this->expectExceptionMessage('bad-encoding'); $this->transcoder->transcode('bla', 'bad-encoding'); } @@ -30,11 +35,9 @@ public function testDetectEncoding() $this->transcoder->transcode('España', null, 'iso-8859-1'); } - /** - * @expectedException \Ddeboer\Transcoder\Exception\IllegalCharacterException - */ public function testTranscodeIllegalCharacter() { + $this->expectException(\Ddeboer\Transcoder\Exception\IllegalCharacterException::class); $this->transcoder->transcode('“', null, 'iso-8859-1'); } diff --git a/tests/MbTranscoderTest.php b/tests/MbTranscoderTest.php index 2eda5a6..97cf01a 100644 --- a/tests/MbTranscoderTest.php +++ b/tests/MbTranscoderTest.php @@ -4,33 +4,32 @@ use Ddeboer\Transcoder\MbTranscoder; -class MbTranscoderTest extends \PHPUnit_Framework_TestCase +class MbTranscoderTest extends \PHPUnit\Framework\TestCase { /** * @var MbTranscoder */ private $transcoder; - protected function setUp() + /** + * @before + */ + protected function doSetUp() { $this->transcoder = new MbTranscoder(); } - /** - * @expectedException \Ddeboer\Transcoder\Exception\UnsupportedEncodingException - * @expectedExceptionMessage bad-encoding - */ public function testTranscodeUnsupportedFromEncoding() { + $this->expectException(\Ddeboer\Transcoder\Exception\UnsupportedEncodingException::class); + $this->expectExceptionMessage('bad-encoding'); $this->transcoder->transcode('bla', 'bad-encoding'); } - /** - * @expectedException \Ddeboer\Transcoder\Exception\UnsupportedEncodingException - * @expectedExceptionMessage bad-encoding - */ public function testTranscodeUnsupportedToEncoding() { + $this->expectException(\Ddeboer\Transcoder\Exception\UnsupportedEncodingException::class); + $this->expectExceptionMessage('bad-encoding'); $this->transcoder->transcode('bla', null, 'bad-encoding'); } @@ -40,12 +39,10 @@ public function testDetectEncoding() $this->transcoder->transcode($result); } - /** - * @expectedException \Ddeboer\Transcoder\Exception\UndetectableEncodingException - * @expectedExceptionMessage is undetectable - */ public function testUndetectableEncoding() { + $this->expectException(\Ddeboer\Transcoder\Exception\UndetectableEncodingException::class); + $this->expectExceptionMessage('is undetectable'); $result = $this->transcoder->transcode( '‘curly quotes make this incompatible with 1252’', null, diff --git a/tests/TranscoderTest.php b/tests/TranscoderTest.php index 802b20e..3e2aae8 100644 --- a/tests/TranscoderTest.php +++ b/tests/TranscoderTest.php @@ -4,14 +4,17 @@ use Ddeboer\Transcoder\Transcoder; -class TranscoderTest extends \PHPUnit_Framework_TestCase +class TranscoderTest extends \PHPUnit\Framework\TestCase { /** * @var Transcoder */ private $transcoder; - protected function setUp() + /** + * @before + */ + protected function doSetUp() { $this->transcoder = Transcoder::create(); }