diff --git a/test/HostnameTest.php b/test/HostnameTest.php index 387237bf5..57433e614 100644 --- a/test/HostnameTest.php +++ b/test/HostnameTest.php @@ -23,11 +23,16 @@ class HostnameTest extends \PHPUnit_Framework_TestCase */ protected $validator; - /** @var string */ + /** + * @var string + */ protected $origEncoding; + public function setUp() { - $this->origEncoding = iconv_get_encoding('internal_encoding'); + $this->origEncoding = PHP_VERSION_ID < 50600 + ? iconv_get_encoding('internal_encoding') + : ini_get('default_charset'); $this->validator = new Hostname(); } @@ -36,7 +41,11 @@ public function setUp() */ public function tearDown() { - iconv_set_encoding('internal_encoding', $this->origEncoding); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', $this->origEncoding); + } else { + ini_set('default_charset', $this->origEncoding); + } } /** @@ -345,7 +354,12 @@ public function testLatinSpecialChars() */ public function testDifferentIconvEncoding() { - iconv_set_encoding('internal_encoding', 'ISO8859-1'); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', 'ISO8859-1'); + } else { + ini_set('default_charset', 'ISO8859-1'); + } + $validator = new Hostname(); $valuesExpected = array( diff --git a/test/StringLengthTest.php b/test/StringLengthTest.php index 769f8fc50..98b162d3b 100644 --- a/test/StringLengthTest.php +++ b/test/StringLengthTest.php @@ -38,7 +38,12 @@ public function setUp() */ public function testBasic() { - iconv_set_encoding('internal_encoding', 'UTF-8'); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', 'UTF-8'); + } else { + ini_set('default_charset', 'UTF-8'); + } + /** * The elements of each array are, in order: * - minimum length @@ -128,7 +133,12 @@ public function testSetMaxExceptionLessThanMin() */ public function testDifferentEncodingWithValidator() { - iconv_set_encoding('internal_encoding', 'UTF-8'); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', 'UTF-8'); + } else { + ini_set('default_charset', 'UTF-8'); + } + $validator = new StringLength(2, 2, 'UTF-8'); $this->assertEquals(true, $validator->isValid('ab'));