Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#6219 from Ocramius/hot…
Browse files Browse the repository at this point in the history
…fix/zendframework/zendframework#6218-iconv-internal-encoding-deprecated-in-php-5.6

zendframework/zendframework#6218 - applying hotfix for `iconv.internal_encoding` deprecation
  • Loading branch information
weierophinney committed May 7, 2014
6 parents 7e87f9c + 1e149f3 + 7264594 + d4303d5 + 0ca818a + 53ca459 commit c619b63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
22 changes: 18 additions & 4 deletions test/HostnameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

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

/**
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 12 additions & 2 deletions test/StringLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'));

Expand Down

0 comments on commit c619b63

Please sign in to comment.