Lines 1-14
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
# |
2 |
# |
3 |
# This Koha test module is a stub! |
3 |
# This Koha test module is a stub! |
4 |
# Add more tests here!!! |
4 |
# Add more tests here!!! |
5 |
|
5 |
|
6 |
use strict; |
6 |
use Modern::Perl; |
7 |
use warnings; |
|
|
8 |
|
7 |
|
9 |
use Test::More tests => 1; |
8 |
use Test::More tests => 7; |
|
|
9 |
|
10 |
use C4::Context; |
10 |
|
11 |
|
11 |
BEGIN { |
12 |
BEGIN { |
12 |
use_ok('C4::Reports::Guided'); |
13 |
use_ok('C4::Reports::Guided'); |
13 |
} |
14 |
} |
|
|
15 |
can_ok( 'C4::Reports::Guided', |
16 |
qw(save_report |
17 |
delete_report) |
18 |
); |
19 |
|
20 |
#Start transaction |
21 |
my $dbh = C4::Context->dbh; |
22 |
$dbh->{RaiseError} = 1; |
23 |
$dbh->{AutoCommit} = 0; |
24 |
|
25 |
$dbh->do(q|DELETE FROM saved_sql|); |
26 |
|
27 |
#Start tests |
28 |
|
29 |
#Test save_report |
30 |
my $count = scalar (keys get_saved_reports()); |
31 |
is ($count , 0, "There is no report"); |
32 |
my $sample_report1 = {borrowernumber => 1,savedsql => 'SQL1',name => 'Name1' , |
33 |
area => 'area1' ,group => 'group1' ,subgroup => 'subgroup1',type => 'type1',notes => 'note1',cache_expiry => 'null' ,public => 'null'}; |
34 |
my $sample_report2 = {borrowernumber => 2,savedsql => 'SQL2',name => 'Name2' , |
35 |
area => 'area2' ,group => 'group2' ,subgroup => 'subgroup2',type => 'type2',notes => 'note2',cache_expiry => 'null' ,public => 'null'}; |
36 |
my $report_id1 = save_report($sample_report1); |
37 |
my $report_id2 = save_report($sample_report2); |
38 |
like($report_id1,'/^\d+$/',"Save_report returns an id"); |
39 |
like($report_id2,'/^\d+$/',"Save_report returns an id"); |
40 |
is ( scalar (keys get_saved_reports()),$count + 2 , "Report1 and report2 have been added"); |
41 |
|
42 |
#Test delete_report |
43 |
#It would be better if delete_report has return values |
44 |
delete_report($report_id1,$report_id2); |
45 |
is ( scalar (keys get_saved_reports()),$count , "Report1 and report2 have been deleted"); |
46 |
#FIX ME: Currently, this test doesn't pass because delete_report doesn't test if one or more parameters are given |
47 |
#is (deleted_report(),undef, "Without id deleted_report returns undef"); |
48 |
|
49 |
#End transaction |
50 |
$dbh->rollback; |
14 |
|
51 |
|
15 |
- |
|
|