| 1 |
<?php |
| 2 |
|
| 3 |
use Jcof\Jcof; |
| 4 |
|
| 5 |
function covertAndRevertJson($jsonString) |
| 6 |
{ |
| 7 |
$data = json_decode($jsonString, true); |
| 8 |
|
| 9 |
$jcofCompressed = Jcof::stringify($data); |
| 10 |
|
| 11 |
$jcofCompressedToArray = Jcof::parse($jcofCompressed); |
| 12 |
|
| 13 |
expect(($data))->toEqual(($jcofCompressedToArray)); |
| 14 |
} |
| 15 |
|
| 16 |
test('example 1', function () { |
| 17 |
$jsonString = file_get_contents(__DIR__.'/../data/circuitsim.json'); |
| 18 |
|
| 19 |
covertAndRevertJson($jsonString); |
| 20 |
}); |
| 21 |
|
| 22 |
test('example 2', function () { |
| 23 |
$jsonString = file_get_contents(__DIR__.'/../data/madrid.json'); |
| 24 |
|
| 25 |
covertAndRevertJson($jsonString); |
| 26 |
}); |
| 27 |
|
| 28 |
test('example 3', function () { |
| 29 |
$jsonString = file_get_contents(__DIR__.'/../data/comets.json'); |
| 30 |
|
| 31 |
covertAndRevertJson($jsonString); |
| 32 |
}); |
| 33 |
|
| 34 |
test('example 4', function () { |
| 35 |
$jsonString = file_get_contents(__DIR__.'/../data/meteorites.json'); |
| 36 |
|
| 37 |
covertAndRevertJson($jsonString); |
| 38 |
}); |
| 39 |
|
| 40 |
test('example 5', function () { |
| 41 |
$jsonString = file_get_contents(__DIR__.'/../data/pokedex.json'); |
| 42 |
|
| 43 |
covertAndRevertJson($jsonString); |
| 44 |
}); |
| 45 |
|
| 46 |
test('example 6', function () { |
| 47 |
$jsonString = file_get_contents(__DIR__.'/../data/pokemon.json'); |
| 48 |
|
| 49 |
covertAndRevertJson($jsonString); |
| 50 |
}); |
| 51 |
|
| 52 |
test('example 7', function () { |
| 53 |
$jsonString = file_get_contents(__DIR__.'/../data/tiny.json'); |
| 54 |
|
| 55 |
covertAndRevertJson($jsonString); |
| 56 |
}); |
| 57 |
|