Bugzilla – Attachment 68267 Details for
Bug 12768
Replacement cost and processing fee management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12768 - Fix up unit tests
Bug-12768---Fix-up-unit-tests.patch (text/plain), 4.50 KB, created by
Nick Clemens (kidclamp)
on 2017-10-18 16:43:25 UTC
(
hide
)
Description:
Bug 12768 - Fix up unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-10-18 16:43:25 UTC
Size:
4.50 KB
patch
obsolete
>From 62b2ba3a0cd050928436bc629335eb1982f1330e Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 10 Oct 2017 10:34:22 -0400 >Subject: [PATCH] Bug 12768 - Fix up unit tests > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Circulation/Chargelostitem.t | 74 ++++++++++++----------------- > 1 file changed, 31 insertions(+), 43 deletions(-) > >diff --git a/t/db_dependent/Circulation/Chargelostitem.t b/t/db_dependent/Circulation/Chargelostitem.t >index b19386a..3ffb295 100644 >--- a/t/db_dependent/Circulation/Chargelostitem.t >+++ b/t/db_dependent/Circulation/Chargelostitem.t >@@ -2,39 +2,43 @@ > > use Modern::Perl; > >+use Test::More tests => 4; > use Test::MockModule; >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ > use C4::Biblio; > use C4::Items; > use C4::Members; >-use C4::Branch; >-use C4::Category; > use C4::Circulation; > use MARC::Record; >-use Test::More tests => 7; > > BEGIN { > use_ok('C4::Accounts'); > } > >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; >+ > $dbh->do(q|DELETE FROM accountlines|); > >-my $branchcode; >-my $branch_created; >-my @branches = keys %{ GetBranches() }; >-if (@branches) { >- $branchcode = $branches[0]; >-} else { >- $branchcode = 'B'; >- ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' }); >- $branch_created = 1; >-} >+t::lib::Mocks::mock_preference('ProcessingFeeNote', 'Test Note'); >+ >+my $library = $builder->build({ >+ source => 'Branch', >+}); >+my $branchcode = $library->{branchcode}; >+ >+my $itemtype = $builder->build({ >+ source => 'Itemtype' >+}); > > my %item_branch_infos = ( > homebranch => $branchcode, > holdingbranch => $branchcode, >+ itype => $itemtype->{itemtype}, > ); > > my ($biblionumber1) = AddBiblio(MARC::Record->new, ''); >@@ -44,20 +48,12 @@ my $itemnumber2 = AddItem({ barcode => '0102', %item_branch_infos }, $biblionumb > my ($biblionumber2) = AddBiblio(MARC::Record->new, ''); > my $itemnumber3 = AddItem({ barcode => '0203', %item_branch_infos }, $biblionumber2); > >-my $categorycode; >-my $category_created; >-my @categories = C4::Category->all; >-if (@categories) { >- $categorycode = $categories[0]->{categorycode} >-} else { >- $categorycode = 'C'; >- $dbh->do( >- "INSERT INTO categories(categorycode) VALUES(?)", undef, $categorycode); >- $category_created = 1; >-} >+my $categorycode = $builder->build({ >+ source => 'Category' >+})->{categorycode}; > > my $borrowernumber = AddMember(categorycode => $categorycode, branchcode => $branchcode); >-my $borrower = GetMember(borrowernumber => $borrowernumber); >+my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed(); > > # Need to mock userenv for AddIssue > my $module = new Test::MockModule('C4::Context'); >@@ -66,19 +62,11 @@ AddIssue($borrower, '0101'); > AddIssue($borrower, '0203'); > > # Begin tests... >-my $processfee = 10; >-my $issues; >-$issues = C4::Circulation::GetIssues({biblionumber => $biblionumber1}); >-my $issue=$issues->[0]; >-$issue->{'processfee'} = $processfee; >-C4::Accounts::chargelostitem($issue, 'test'); >- >-my @accountline = C4::Accounts::getcharges($borrowernumber); >- >-is( scalar(@accountline), 1, 'accountline should have 1 row' ); >-is( int($accountline[0]->{amount}), $processfee, "The accountline amount should be precessfee value " ); >-is( $accountline[0]->{accounttype}, 'PF', "The accountline accounttype should be PF " ); >-is( $accountline[0]->{borrowernumber}, $borrowernumber, "The accountline borrowernumber should be the example borrowernumber" ); >-my $itemnumber = C4::Items::GetItemnumberFromBarcode('0101'); >-is( $accountline[0]->{itemnumber}, $itemnumber, "The accountline itemnumber should the linked with barcode '0101'" ); >-is( $accountline[0]->{description}, 'test ' . $issue->{itemnumber}, "The accountline description should be 'test'" ); >+my $issue = Koha::Checkouts->search( { borrowernumber => $borrowernumber } )->next()->unblessed(); >+C4::Accounts::chargelostitem( $borrowernumber, $issue->{itemnumber}, '1.00'); >+ >+my $accountline = Koha::Account::Lines->search( { borrowernumber => $borrowernumber, accounttype => 'PF' } )->next(); >+ >+is( int($accountline->amount), $itemtype->{processfee}, "The accountline amount should be precessfee value " ); >+is( $accountline->itemnumber, $itemnumber1, "The accountline itemnumber should the linked with barcode '0101'" ); >+is( $accountline->note, C4::Context->preference("ProcessingFeeNote"), "The accountline description should be 'test'" ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12768
:
34333
|
34334
|
36350
|
36505
|
36506
|
36552
|
36553
|
36554
|
36555
|
38365
|
38367
|
38368
|
38375
|
39298
|
39299
|
39300
|
39999
|
40000
|
40001
|
40002
|
42157
|
42158
|
43181
|
43546
|
64775
|
64776
|
66760
|
66761
|
67875
|
67876
|
67877
|
67878
|
67891
|
67892
|
67893
|
67894
|
67895
|
67896
|
67897
|
68035
|
68036
|
68037
|
68038
|
68039
|
68040
|
68041
|
68042
|
68076
|
68264
|
68265
|
68266
| 68267 |
68268
|
68269
|
68270
|
68271
|
68272
|
68273
|
68274
|
68332
|
68415
|
68416
|
68417
|
68426
|
68427