Lines 52-58
subtest 'Basic Koha object tests' => sub {
Link Here
|
52 |
my $item = $builder->build_sample_item; |
52 |
my $item = $builder->build_sample_item; |
53 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
53 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
54 |
|
54 |
|
55 |
Koha::Statistic->insert( |
55 |
Koha::Statistic->new( |
56 |
{ |
56 |
{ |
57 |
type => 'issue', |
57 |
type => 'issue', |
58 |
branch => $library->branchcode, |
58 |
branch => $library->branchcode, |
Lines 63-69
subtest 'Basic Koha object tests' => sub {
Link Here
|
63 |
ccode => $item->ccode, |
63 |
ccode => $item->ccode, |
64 |
interface => C4::Context->interface, |
64 |
interface => C4::Context->interface, |
65 |
} |
65 |
} |
66 |
); |
66 |
)->store; |
67 |
|
67 |
|
68 |
my $stat = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next; |
68 |
my $stat = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next; |
69 |
is( $stat->borrowernumber, $patron->borrowernumber, 'Patron is there' ); |
69 |
is( $stat->borrowernumber, $patron->borrowernumber, 'Patron is there' ); |
Lines 107-113
subtest 'Test exceptions in ->new' => sub {
Link Here
|
107 |
$schema->storage->txn_rollback; |
107 |
$schema->storage->txn_rollback; |
108 |
}; |
108 |
}; |
109 |
|
109 |
|
110 |
subtest 'Test ->insert (fka UpdateStats)' => sub { |
110 |
subtest 'Test new->store (fka UpdateStats)' => sub { |
111 |
plan tests => 15; |
111 |
plan tests => 15; |
112 |
$schema->storage->txn_begin; |
112 |
$schema->storage->txn_begin; |
113 |
|
113 |
|
Lines 154-160
subtest 'Test ->insert (fka UpdateStats)' => sub {
Link Here
|
154 |
|
154 |
|
155 |
sub insert_and_fetch { |
155 |
sub insert_and_fetch { |
156 |
my $params = shift; |
156 |
my $params = shift; |
157 |
my $statistic = Koha::Statistic->insert($params); |
157 |
my $statistic = Koha::Statistic->new($params)->store; |
158 |
return Koha::Statistics->search( { borrowernumber => $test_params->{borrowernumber} } )->last; |
158 |
return Koha::Statistics->search( { borrowernumber => $test_params->{borrowernumber} } )->last; |
159 |
|
159 |
|
160 |
# FIXME discard_changes would be nicer, but we dont have a PK (yet) |
160 |
# FIXME discard_changes would be nicer, but we dont have a PK (yet) |
161 |
- |
|
|