znt/module/testcase/test/model/xmltoarray.php

34 lines
1.6 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 testcaseModel::xmlToArray();
timeout=0
cid=19028
- 步骤1简单XML转换 @{"root":{"item":"test"}}
- 步骤2命名空间XML转换 @{"root":{"item":"test"}}
- 步骤3带属性XML转换 @{"root":{"id":"123","item":"test"}}
- 步骤4文本内容XML转换 @{"root":"Simple text content"}
- 步骤5嵌套XML转换 @{"root":{"parent":{"child":"nested"}}}
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$testcaseTest = new testcaseModelTest();
// 4. 🔴 强制要求必须包含至少5个测试步骤
r($testcaseTest->xmlToArrayTest('<root><item>test</item></root>')) && p() && e('{"root":{"item":"test"}}'); // 步骤1简单XML转换
r($testcaseTest->xmlToArrayTest('<root xmlns:ns="http://example.com"><ns:item>test</ns:item></root>')) && p() && e('{"root":{"item":"test"}}'); // 步骤2命名空间XML转换
r($testcaseTest->xmlToArrayTest('<root id="123"><item>test</item></root>')) && p() && e('{"root":{"id":"123","item":"test"}}'); // 步骤3带属性XML转换
r($testcaseTest->xmlToArrayTest('<root>Simple text content</root>')) && p() && e('{"root":"Simple text content"}'); // 步骤4文本内容XML转换
r($testcaseTest->xmlToArrayTest('<root><parent><child>nested</child></parent></root>')) && p() && e('{"root":{"parent":{"child":"nested"}}}'); // 步骤5嵌套XML转换