Skip to content

Fix CI for newer PHP versions #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,5 +33,8 @@
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"scripts": {
"test": "vendor/bin/simple-phpunit"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
convertErrorsToExceptions="false"
>
<testsuites>
<testsuite>
<testsuite name="Tests">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
Expand Down
21 changes: 12 additions & 9 deletions tests/IconvTranscoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand Down
25 changes: 11 additions & 14 deletions tests/MbTranscoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions tests/TranscoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down