Skip to content

Commit

Permalink
Add test for JSON::encode(pretty: true)
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Nov 9, 2024
1 parent 9cddba2 commit dd3fa82
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions tests/Data/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ public function testDecodeInvalid2()
Json::decode(1);
}

/**
* @covers ::encode
*/
public function testEncodeUnicode()
{
$string = 'здравей';
$this->assertSame('"' . $string . '"', Json::encode($string));
}

/**
* @covers ::decode
*/
Expand All @@ -87,4 +78,34 @@ public function testDecodeCorrupted2()

Json::decode('true');
}

/**
* @covers ::encode
*/
public function testEncodePretty()
{
$array = [
'name' => 'Homer',
'children' => ['Lisa', 'Bart', 'Maggie']
];

$data = Json::encode($array, pretty: true);
$this->assertSame('{
"name": "Homer",
"children": [
"Lisa",
"Bart",
"Maggie"
]
}', $data);
}

/**
* @covers ::encode
*/
public function testEncodeUnicode()
{
$string = 'здравей';
$this->assertSame('"' . $string . '"', Json::encode($string));
}
}

0 comments on commit dd3fa82

Please sign in to comment.