. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace tests\unit\Espo\Core\Utils; use Espo\Core\Utils\Json; use JsonException; class JsonTest extends \PHPUnit\Framework\TestCase { protected function setUp(): void { } protected function tearDown() : void { } public function testDecodeBad1() { $value = '{'; $this->expectException(JsonException::class); Json::decode($value); } public function testEncode() { $testVal = ['testOption' => 'Test']; $this->assertEquals(json_encode($testVal), Json::encode($testVal)); } public function testDecode() { $value = ['testOption' => 'Test']; $this->assertEquals($value, Json::decode(json_encode($value), true)); $test = '{"folder":"data\/logs"}'; $this->assertEquals('data/logs', Json::decode($test)->folder); } }