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

Commit

Permalink
Merge branch 'hotfix/unit-tests' of https://github.com/Maks3w/zf2 int…
Browse files Browse the repository at this point in the history
…o hotfix/tests-skipped
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function _encodeArray(&$array)
* If value type is not a string, number, boolean, or null, the string
* 'null' is returned.
*
* @param $value mixed
* @param mixed $value
* @return string
*/
protected function _encodeDatum(&$value)
Expand All @@ -244,7 +244,7 @@ protected function _encodeDatum(&$value)

if (is_int($value) || is_float($value)) {
$result = (string) $value;
$result = str_replace(",", ".", $result);
$result = str_replace(',', '.', $result);
} elseif (is_string($value)) {
$result = $this->_encodeString($value);
} elseif (is_bool($value)) {
Expand Down
16 changes: 8 additions & 8 deletions test/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

namespace ZendTest\Json;

use Zend\Json;

/**
Expand Down Expand Up @@ -693,17 +694,16 @@ public function testUtf8JSONExprFinder()
/**
* @group ZF-4437
*/
public function testKommaDecimalIsConvertedToCorrectJSONWithDot()
public function testCommaDecimalIsConvertedToCorrectJSONWithDot()
{
$localeInfo = localeconv();
if($localeInfo['decimal_point'] != ',') {
$this->markTestSkipped("This test only works for platforms where , is the decimal point separator.");
setlocale(LC_ALL, 'Spanish_Spain', 'es_ES', 'es_ES.utf-8');
if (strcmp('1,2', (string)floatval(1.20)) != 0) {
$this->markTestSkipped('This test only works for platforms where "," is the decimal point separator.');
}

Json\Json::$useBuiltinEncoderDecoder = true;
$this->assertEquals("[1.20, 1.68]", Json\Encoder::encode(array(
(float)"1,20", (float)"1,68"
)));

$actual = Json\Encoder::encode(array(floatval(1.20), floatval(1.68)));
$this->assertEquals('[1.2,1.68]', $actual);
}

public function testEncodeObjectImplementingIterator()
Expand Down

0 comments on commit 80a9fd5

Please sign in to comment.