summaryrefslogtreecommitdiff
path: root/tests/it_pipe.t
blob: 56ee6724aac72f0c43a356045294067ef55b833f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/www/server/bin/php
<?php

# csv()
$pipe = new it_pipe(array('data' => array("a\tb", "1\t2")));
is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");

$pipe = new it_pipe(array('data' => array("a;b",   "1;2")));
is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");

$pipe = new it_pipe(array('data' => array("a,b",   "1,2")));
is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");

$pipe = new it_pipe(array('data' => array("a\tb", "1\t2")));
is(json_encode($pipe->csv("c,d")), '[{"c":"1","d":"2"}]',           "it_pipe::csv()");

$pipe = new it_pipe(array('data' => array("\t", "1\t2")));
is(json_encode($pipe->csv()),        '[{"field0":"1","field1":"2"}]', "it_pipe::csv()");