提交 b107313f 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

test xml, json output

上级 b577f233
>> 104
>> field: id
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=generate yaml from database table ddl
cid=0
pid=0
[group]
1. count >>
2. line of id field >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -i ../test/definition/_ddl.sql -o ../test/output", $output);
$str = join("\n", $output);
print("$str\n");
$content = file_get_contents('../test/output/zt_action.yaml');
$arr = explode("\n", $content);
$count = sprintf("%d", count($arr));
print(">> $count\n");
$line = $arr[5];
print(">> $line\n");
\ No newline at end of file
>> '济南市-青岛市-淄博市'
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=query excel
cid=0
pid=0
[group]
1. output >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/refer.yaml -c 7 -field excel -o ../test/output/output.txt -f text", $output);
print(">> $output[0]\n");
\ No newline at end of file
>> Usage:
>> 3
>> 'a,b,c'
>> output.txt
>> '1,3,5'
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=basic
cid=0
pid=0
[group]
1. usage output >>
2. basic output >>
3. step output >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -h", $output);
print(">> $output[0]\n");
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 3 -field basic -o ../test/output/output.txt -f text", $output);
$count = sprintf("%d", count($output));
print(">> $count\n");
print(">> $output[0]\n");
$output = [];
exec('ls ../test/output/output.txt -f text', $output);
print(">> $output[0]\n");
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 7 -field step -o ../test/output/output.txt -f text", $output);
print(">> $output[0]\n");
\ No newline at end of file
>> 2, 1.100, char is c
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=defferent data type with format
cid=0
pid=0
[group]
1. defferent data type with format >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/format.yaml -c 3 -field int,float,char -o ../test/output/output.txt -f text", $output);
print(">> $output[1]\n");
\ No newline at end of file
>> {a b}
>> ='1,2' '3,4'-
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=field inherit
cid=0
pid=0
[group]
1. inherit from basic field >>
2. inherit from reference field >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -d ../test/definition/basic.yaml -y ../test/definition/inherit.yaml -c 3 -field basic -o ../test/output/output.txt -f text", $output);
print(">> $output[0]\n");
$output = [];
exec("$cmd -d ../test/definition/refer.yaml -y ../test/definition/inherit.yaml -c 3 -field refer2 -o ../test/output/output.txt -f text", $output);
print(">> $output[0]\n");
\ No newline at end of file
>> 1. 'X12,Y34'
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=field nested
cid=0
pid=0
[group]
1. output >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/nested.yaml -c 3 -field nested", $output);
print(">> $output[0]\n");
\ No newline at end of file
>> 6
>> is random
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=random
cid=0
pid=0
[group]
1. output >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 7 -field random -o ../test/output/output.txt -f text", $output);
$line = $output[0];
print("Got $line\n");
// 1,2,2,2,8,1
$numbs = explode(",", $line);
$count = sprintf("%d", count($numbs));
print(">> $count\n");
$result = 'not random';
$i = 0;
for($i = 0; $i < $count; $i++) {
if ($numbs[$i] != $i + 1) { // at lease one not equal sequence numb 1,2,3,4,5,6
$result = 'is random';
break;
}
}
print(">> $result\n");
\ No newline at end of file
>> 192.168.0.1
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=reference
cid=0
pid=0
[group]
1. output >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/refer.yaml -c 7 -field refer -o ../test/output/output.txt -f text", $output);
print(">> $output[0]\n");
\ No newline at end of file
>> 4
>> a1
>> a
>> a
>> INSERT INTO (char,numb) VALUES('a','1');
\ No newline at end of file
#!/usr/bin/env php
<?php
/**
[case]
title=basic
cid=0
pid=0
[group]
1. count of text >>
2. value from text >>
3. value from json >>
4. value from xml >>
5. first line of sql >>
[esac]
*/
include_once __DIR__ . DIRECTORY_SEPARATOR . '_utils.php';
$cmd = getZDCmd();
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 3 -field char,numb -o ../test/output/output.txt -f text", $output);
$content = file_get_contents('../test/output/output.txt');
$arr = explode("\n", $content);
$count = sprintf("%d", count($arr));
print(">> $count\n");
print(">> $arr[0]\n");
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 3 -field char,numb -o ../test/output/output.json -f json", $output);
$content = file_get_contents('../test/output/output.json');
$json = json_decode($content);
$val = $json[0][0];
print(">> $val\n");
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 3 -field char,numb -o ../test/output/output.xml -f xml", $output);
$xml = simplexml_load_file('../test/output/output.xml');
$content = file_get_contents('../test/output/output.xml');
$val = $xml->table->row->col[0];
print(">> $val\n");
$output = [];
exec("$cmd -y ../test/definition/basic.yaml -c 3 -field char,numb -o ../test/output/output.sql -f sql", $output);
$content = file_get_contents('../test/output/output.sql');
$arr = explode("\n", $content);
print(">> $arr[0]\n");
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册