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

(-)a/t/db_dependent/Circulation/issue.t (-16 / +34 lines)
Lines 16-21 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Data::Dumper;
19
20
20
use Koha::DateUtils;
21
use Koha::DateUtils;
21
use DateTime::Duration;
22
use DateTime::Duration;
Lines 143-148 $dbh->do( Link Here
143
    $samplecat->{category_type}
144
    $samplecat->{category_type}
144
);
145
);
145
146
147
my $TEST_ITEMTYPE = "_T_ITYPE";
148
my %TEST_ITEMTYPE_REC = (
149
    itemtype => $TEST_ITEMTYPE,
150
    rentalcharge => "1.50",
151
);
152
Koha::ItemType->new(\%TEST_ITEMTYPE_REC)->store;
153
154
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
155
146
#Add biblio and item
156
#Add biblio and item
147
my $record = MARC::Record->new();
157
my $record = MARC::Record->new();
148
$record->append_fields(
158
$record->append_fields(
Lines 158-164 my @sampleitem1 = C4::Items::AddItem( Link Here
158
        homebranch     => $samplebranch1->{branchcode},
168
        homebranch     => $samplebranch1->{branchcode},
159
        holdingbranch  => $samplebranch1->{branchcode},
169
        holdingbranch  => $samplebranch1->{branchcode},
160
        issue          => 1,
170
        issue          => 1,
161
        reserve        => 1
171
        reserve        => 1,
172
        itype          => $TEST_ITEMTYPE,
162
    },
173
    },
163
    $biblionumber
174
    $biblionumber
164
);
175
);
Lines 170-176 my @sampleitem2 = C4::Items::AddItem( Link Here
170
        homebranch     => $samplebranch2->{branchcode},
181
        homebranch     => $samplebranch2->{branchcode},
171
        holdingbranch  => $samplebranch2->{branchcode},
182
        holdingbranch  => $samplebranch2->{branchcode},
172
        notforloan     => 1,
183
        notforloan     => 1,
173
        issue          => 1
184
        issue          => 1,
185
        itype          => $TEST_ITEMTYPE,
174
    },
186
    },
175
    $biblionumber
187
    $biblionumber
176
);
188
);
Lines 209-217 my $userenv = C4::Context->userenv Link Here
209
221
210
#Begin Tests
222
#Begin Tests
211
223
224
my $bib = GetBiblioFromItemNumber( $item_id1);
225
$query = " SELECT count(*) FROM accountlines";
226
my $sth = $dbh->prepare($query);
227
$sth->execute;
228
my $countaccount = $sth -> fetchrow_array;
229
is ($countaccount,0,"0 accountline exists");
230
212
#Test AddIssue
231
#Test AddIssue
213
$query = " SELECT count(*) FROM issues";
232
$query = " SELECT count(*) FROM issues";
214
my $sth = $dbh->prepare($query);
233
$sth = $dbh->prepare($query);
215
$sth->execute;
234
$sth->execute;
216
my $countissue = $sth -> fetchrow_array;
235
my $countissue = $sth -> fetchrow_array;
217
is ($countissue ,0, "there is no issue");
236
is ($countissue ,0, "there is no issue");
Lines 232-251 my $issue_id2 = $dbh->last_insert_id( undef, undef, 'issues', undef ); Link Here
232
251
233
$sth->execute;
252
$sth->execute;
234
$countissue = $sth -> fetchrow_array;
253
$countissue = $sth -> fetchrow_array;
235
is ($countissue,1,"1 issues have been added");
254
is ($countissue,1,"1 issue has been added");
236
255
237
#Test AddIssuingCharge
256
#Test AddIssuingCharge
238
$query = " SELECT count(*) FROM accountlines";
257
$query = " SELECT * FROM accountlines";
239
$sth = $dbh->prepare($query);
258
my $acc_sth = $dbh->prepare($query);
240
$sth->execute;
259
$acc_sth->execute;
241
my $countaccount = $sth -> fetchrow_array;
260
my $account = $acc_sth -> fetchall_arrayref({});
242
is ($countaccount,0,"0 accountline exists");
261
ok (scalar(@$account) == 1 && $account->[0]{accounttype} eq "Rent","accountline has been added")
243
is( C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, 10 ),
262
  or diag( Dumper($account) );
244
    1, "An issuing charge has been added" );
263
245
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
246
$sth->execute;
247
$countaccount = $sth -> fetchrow_array;
248
is ($countaccount,1,"1 accountline has been added");
249
264
250
#Test AddRenewal
265
#Test AddRenewal
251
my $datedue3 =
266
my $datedue3 =
Lines 256-261 like( Link Here
256
    qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
271
    qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
257
    "AddRenewal returns a date"
272
    "AddRenewal returns a date"
258
);
273
);
274
$acc_sth->execute;
275
$account = $acc_sth -> fetchall_arrayref({});
276
ok (scalar(@$account) == 2 && $account->[1]{accounttype} eq "Rent","another accountline has been added")
277
  or diag( Dumper($account) );
259
278
260
#Test GetBiblioIssues
279
#Test GetBiblioIssues
261
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
280
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
262
- 

Return to bug 14803