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

(-)a/t/db_dependent/Koha/Statistics.t (-1 / +4 lines)
Lines 19-28 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Statistics;
25
use Koha::Statistics;
26
use C4::Context;
26
use C4::Stats qw( UpdateStats );
27
use C4::Stats qw( UpdateStats );
27
28
28
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
Lines 43-48 C4::Stats::UpdateStats( Link Here
43
        itemtype       => $item->effective_itemtype,
44
        itemtype       => $item->effective_itemtype,
44
        location       => $item->location,
45
        location       => $item->location,
45
        ccode          => $item->ccode,
46
        ccode          => $item->ccode,
47
        interface      => C4::Context->interface
46
    }
48
    }
47
);
49
);
48
50
Lines 52-56 is( $stat->borrowernumber, $patron->borrowernumber, 'Patron is there' ); Link Here
52
is( $stat->branch,         $library->branchcode,    'Library is there' );
54
is( $stat->branch,         $library->branchcode,    'Library is there' );
53
is( ref( $stat->item ), 'Koha::Item', '->item returns a Koha::Item object' );
55
is( ref( $stat->item ), 'Koha::Item', '->item returns a Koha::Item object' );
54
is( $stat->item->itemnumber, $item->itemnumber, '->item works great' );
56
is( $stat->item->itemnumber, $item->itemnumber, '->item works great' );
57
is( $stat->interface, 'opac', 'Interface is recorded successfully' );
55
58
56
$schema->storage->txn_rollback;
59
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Stats.t (-5 / +9 lines)
Lines 4-10 use Modern::Perl; Link Here
4
use C4::Stats qw( UpdateStats );
4
use C4::Stats qw( UpdateStats );
5
use Koha::Database;
5
use Koha::Database;
6
6
7
use Test::More tests => 18;
7
use Test::More tests => 19;
8
8
9
BEGIN {
9
BEGIN {
10
    use_ok('C4::Stats', qw( UpdateStats ));
10
    use_ok('C4::Stats', qw( UpdateStats ));
Lines 33-38 my $params = { Link Here
33
              itemtype => "BK",
33
              itemtype => "BK",
34
              location => "LOC",
34
              location => "LOC",
35
              ccode => "CODE",
35
              ccode => "CODE",
36
              interface => "INTERFACE",
36
};
37
};
37
my $return_error;
38
my $return_error;
38
39
Lines 105-111 $params = { Link Here
105
              itemtype => "BK",
106
              itemtype => "BK",
106
              location => "LOC",
107
              location => "LOC",
107
              ccode => "CODE",
108
              ccode => "CODE",
108
              type => "return"
109
              type => "return",
110
              interface => "INTERFACE",
109
};
111
};
110
UpdateStats ($params);
112
UpdateStats ($params);
111
my $sth = $dbh->prepare("SELECT * FROM statistics");
113
my $sth = $dbh->prepare("SELECT * FROM statistics");
Lines 119-124 is ($params->{other}, $line->{other}, "UpdateStats save other Link Here
119
is ($params->{itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
121
is ($params->{itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
120
is ($params->{location},       $line->{location},       "UpdateStats save location param in location field of statistics table");
122
is ($params->{location},       $line->{location},       "UpdateStats save location param in location field of statistics table");
121
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
123
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
124
is ($params->{interface},      $line->{interface},      "UpdateStats save interface param in interface field of statistics table");
122
125
123
$dbh->do(q|DELETE FROM statistics|);
126
$dbh->do(q|DELETE FROM statistics|);
124
$params = {
127
$params = {
Lines 129-135 $params = { Link Here
129
    other          => "bla",
132
    other          => "bla",
130
    itemtype       => "BK",
133
    itemtype       => "BK",
131
    ccode          => "CODE",
134
    ccode          => "CODE",
132
    type           => "return"
135
    type           => "return",
136
    interface      => "INTERFACE",
133
};
137
};
134
UpdateStats($params);
138
UpdateStats($params);
135
$sth = $dbh->prepare("SELECT * FROM statistics");
139
$sth = $dbh->prepare("SELECT * FROM statistics");
Lines 148-154 $params = { Link Here
148
    itemtype       => "BK",
152
    itemtype       => "BK",
149
    location       => undef,
153
    location       => undef,
150
    ccode          => "CODE",
154
    ccode          => "CODE",
151
    type           => "return"
155
    type           => "return",
156
    interface      => "interface"
152
};
157
};
153
UpdateStats($params);
158
UpdateStats($params);
154
$sth = $dbh->prepare("SELECT * FROM statistics");
159
$sth = $dbh->prepare("SELECT * FROM statistics");
155
- 

Return to bug 30928