Files
EasySoft-ZenTaoPMS/module/bi/test/model/jsonencode.php
T
2025-09-15 15:06:11 +08:00

27 lines
1.0 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/bi.unittest.class.php';
/**
title=测试 biModel::jsonEncode();
timeout=0
cid=0
- 步骤1:空值情况 @~~
- 步骤2:标量情况 @test_string
- 步骤3:数组情况 @{"key":"value"}
- 步骤4:对象情况 @{"name":"test","id":1}
- 步骤5:复杂数组情况 @{"users":["admin","user1"],"count":2}
*/
$biTest = new biTest();
r($biTest->jsonEncodeTest(null)) && p() && e('~~'); // 步骤1:空值情况
r($biTest->jsonEncodeTest('test_string')) && p() && e('test_string'); // 步骤2:标量情况
r($biTest->jsonEncodeTest(array('key' => 'value'))) && p() && e('{"key":"value"}'); // 步骤3:数组情况
r($biTest->jsonEncodeTest((object)array('name' => 'test', 'id' => 1))) && p() && e('{"name":"test","id":1}'); // 步骤4:对象情况
r($biTest->jsonEncodeTest(array('users' => array('admin', 'user1'), 'count' => 2))) && p() && e('{"users":["admin","user1"],"count":2}'); // 步骤5:复杂数组情况