-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDumperTest.php
42 lines (33 loc) · 954 Bytes
/
DumperTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace Nuglif\Nacl;
class DumperTest extends \PHPUnit\Framework\TestCase
{
public static function getJsonFiles(): iterable
{
$files = glob(__DIR__ . '/json/*.json');
$testCases = [];
for ($i = 0; $i <= Dumper::QUOTE_STR + 1; ++$i) {
foreach ($files as $file) {
$testCases[] = [ $i, file_get_contents($file) ];
}
}
return $testCases;
}
/**
* @dataProvider getJsonFiles
* @test
*/
public function parsedDumpOutputIsEqualToDumpInput($options, $json)
{
$expected = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
$dumper = new Dumper($options);
$nacl = $dumper->dump($expected);
try {
$result = Nacl::parse($nacl);
} catch (\Exception) {
$result = null;
}
$this->assertSame($expected, $result, $nacl);
}
}