forked from Koha-Community/Koha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutput_JSONStream.t
executable file
·32 lines (26 loc) · 1.15 KB
/
Output_JSONStream.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
#
# This Koha test module is a stub!
# Add more tests here!!!
use strict;
use warnings;
use Test::More tests => 10;
BEGIN {
use_ok('C4::Output::JSONStream');
}
my $json = new C4::Output::JSONStream;
is($json->output,'{}',"Making sure JSON output is blank just after its created.");
$json->param( issues => [ 'yes!', 'please', 'no' ] );
is($json->output,'{"issues":["yes!","please","no"]}',"Making sure JSON output has added what we told it to.");
$json->param( stuff => ['realia'] );
like($json->output,'/"stuff":\["realia"\]/',"Making sure JSON output has added more params correctly.");
like($json->output,'/"issues":\["yes!","please","no"\]/',"Making sure existing elements remain in JSON output");
$json->param( stuff => ['fun','love'] );
like($json->output,'/"stuff":\["fun","love"\]/',"Making sure JSON output can overwrite params.");
like($json->output,'/"issues":\["yes!","please","no"\]/',"Making non overwitten elements remain in JSON output");
eval{$json->param( die )};
ok($@,'Dies');
eval{$json->param( die => ['yes','sure','now'])};
ok(!$@,'Does not die.');
eval{$json->param( die => ['yes','sure','now'], die2 =>)};
ok($@,'Dies.');