View | Details | Raw Unified | Return to bug 10761
Collapse All | Expand All

(-)a/t/db_dependent/Reports_Guided.t (-6 / +66 lines)
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(
16
    'C4::Reports::Guided',
17
    qw(save_report
18
      delete_report)
19
);
20
21
#Start transaction
22
my $dbh = C4::Context->dbh;
23
$dbh->{RaiseError} = 1;
24
$dbh->{AutoCommit} = 0;
25
26
$dbh->do(q|DELETE FROM saved_sql|);
27
28
#Start tests
29
30
#Test save_report
31
my $count = scalar( keys get_saved_reports() );
32
is( $count, 0, "There is no report" );
33
my $sample_report1 = {
34
    borrowernumber => 1,
35
    savedsql       => 'SQL1',
36
    name           => 'Name1',
37
    area           => 'area1',
38
    group          => 'group1',
39
    subgroup       => 'subgroup1',
40
    type           => 'type1',
41
    notes          => 'note1',
42
    cache_expiry   => 'null',
43
    public         => 'null'
44
};
45
my $sample_report2 = {
46
    borrowernumber => 2,
47
    savedsql       => 'SQL2',
48
    name           => 'Name2',
49
    area           => 'area2',
50
    group          => 'group2',
51
    subgroup       => 'subgroup2',
52
    type           => 'type2',
53
    notes          => 'note2',
54
    cache_expiry   => 'null',
55
    public         => 'null'
56
};
57
my $report_id1 = save_report($sample_report1);
58
my $report_id2 = save_report($sample_report2);
59
like( $report_id1, '/^\d+$/', "Save_report returns an id" );
60
like( $report_id2, '/^\d+$/', "Save_report returns an id" );
61
is( scalar( keys get_saved_reports() ),
62
    $count + 2, "Report1 and report2 have been added" );
63
64
#Test delete_report
65
#It would be better if delete_report has return values
66
delete_report( $report_id1, $report_id2 );
67
is( scalar( keys get_saved_reports() ),
68
    $count, "Report1 and report2 have been deleted" );
69
70
#FIX ME: Currently, this test doesn't pass because delete_report doesn't test if one or more parameters are given
71
#is (deleted_report(),undef, "Without id deleted_report returns undef");
72
73
#End transaction
74
$dbh->rollback;
14
75
15
- 

Return to bug 10761