Bugzilla – Attachment 46521 Details for
Bug 14610
Add ability to place article requests in Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14610 - Add unit tests
Bug-14610---Add-unit-tests.patch (text/plain), 8.76 KB, created by
Kyle M Hall (khall)
on 2016-01-12 12:10:21 UTC
(
hide
)
Description:
Bug 14610 - Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-01-12 12:10:21 UTC
Size:
8.76 KB
patch
obsolete
>From 5867e05e3ce60e46ecf6ca3e1df690d970587377 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 7 Oct 2015 12:26:37 -0400 >Subject: [PATCH] Bug 14610 - Add unit tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Jennifer Schmidt <jschmidt@switchinc.org> >--- > t/db_dependent/ArticleRequests.t | 176 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 176 insertions(+) > create mode 100755 t/db_dependent/ArticleRequests.t > >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >new file mode 100755 >index 0000000..7d48ffa >--- /dev/null >+++ b/t/db_dependent/ArticleRequests.t >@@ -0,0 +1,176 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use POSIX qw(strftime); >+ >+use Test::More tests => 49; >+use Koha::Database; >+ >+use Koha::Biblio; >+use Koha::Borrower; >+use Koha::Branch; >+ >+BEGIN { >+ use_ok('Koha::ArticleRequest'); >+ use_ok('Koha::ArticleRequests'); >+ use_ok('Koha::ArticleRequest::Status'); >+} >+ >+my $schema = Koha::Database->new()->schema(); >+$schema->storage->txn_begin(); >+ >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do("DELETE FROM issuingrules"); >+ >+my $biblio = Koha::Biblio->new()->store(); >+ok( $biblio->id, 'Koha::Biblio created' ); >+ >+my $biblioitem = $schema->resultset('Biblioitem')->new( >+ { >+ biblionumber => $biblio->id >+ } >+)->insert(); >+ok( $biblioitem->id, 'biblioitem created' ); >+ >+my $item = Koha::Item->new( >+ { >+ biblionumber => $biblio->id, >+ biblioitemnumber => $biblioitem->id, >+ itype => $schema->resultset('Itemtype')->search()->next()->itemtype(), >+ } >+)->store(); >+ok( $item->id, 'Koha::Item created' ); >+ >+my $branch = Koha::Branches->search()->next(); >+my $category = $schema->resultset('Category')->next(); >+my $patron = Koha::Borrower->new( >+ { >+ categorycode => $category->id, >+ branchcode => $branch->id, >+ } >+)->store(); >+ok( $patron->id, 'Koha::Borrower created' ); >+ >+my $article_request = Koha::ArticleRequest->new( >+ { >+ borrowernumber => $patron->id, >+ biblionumber => $biblio->id, >+ itemnumber => $item->id, >+ } >+)->store(); >+$article_request = Koha::ArticleRequests->find( $article_request->id ); >+ok( $article_request->id, 'Koha::ArticleRequest created' ); >+ >+is( $article_request->status, Koha::ArticleRequest::Status::Open, 'New article request has status of Open' ); >+$article_request->process(); >+is( $article_request->status, Koha::ArticleRequest::Status::Processing, '$ar->process() changes status to Processing' ); >+$article_request->complete(); >+is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->complete() changes status to Completed' ); >+$article_request->cancel(); >+is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' ); >+$article_request->status(Koha::ArticleRequest::Status::Open); >+$article_request->store(); >+ >+is( $article_request->biblio->id, $biblio->id, '$ar->biblio() gets corrosponding Koha::Biblio object' ); >+is( $article_request->item->id, $item->id, '$ar->item() gets corrosponding Koha::Item object' ); >+is( $article_request->borrower->id, $patron->id, '$ar->borrower() gets corrosponding Koha::Borrower object' ); >+ >+my $ar = $patron->article_requests(); >+is( ref($ar), 'Koha::ArticleRequests', '$patron->article_requests returns Koha::ArticleRequests object' ); >+is( $ar->next->id, $article_request->id, 'Returned article request matches' ); >+ >+is( $patron->article_requests_current()->count(), 1, 'Open request returned for article_requests_current' ); >+$article_request->process(); >+is( $patron->article_requests_current()->count(), 1, 'Processing request returned for article_requests_current' ); >+$article_request->complete(); >+is( $patron->article_requests_current()->count(), 0, 'Completed request not returned for article_requests_current' ); >+$article_request->cancel(); >+is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' ); >+ >+$article_request->status(Koha::ArticleRequest::Status::Open); >+$article_request->store(); >+ >+is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' ); >+$article_request->process(); >+is( $patron->article_requests_finished()->count(), 0, 'Processing request returned for article_requests_finished' ); >+$article_request->complete(); >+$article_request->cancel(); >+is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' ); >+ >+$article_request->status(Koha::ArticleRequest::Status::Open); >+$article_request->store(); >+ >+$ar = $biblio->article_requests(); >+is( ref($ar), 'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' ); >+is( $ar->next->id, $article_request->id, 'Returned article request matches' ); >+ >+is( $biblio->article_requests_current()->count(), 1, 'Open request returned for article_requests_current' ); >+$article_request->process(); >+is( $biblio->article_requests_current()->count(), 1, 'Processing request returned for article_requests_current' ); >+$article_request->complete(); >+is( $biblio->article_requests_current()->count(), 0, 'Completed request not returned for article_requests_current' ); >+$article_request->cancel(); >+is( $biblio->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' ); >+ >+$article_request->status(Koha::ArticleRequest::Status::Open); >+$article_request->store(); >+ >+is( $biblio->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' ); >+$article_request->process(); >+is( $biblio->article_requests_finished()->count(), 0, 'Processing request returned for article_requests_finished' ); >+$article_request->complete(); >+$article_request->cancel(); >+is( $biblio->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' ); >+ >+my $rule; >+$rule = $schema->resultset('Issuingrule') >+ ->new( { categorycode => '*', itemtype => '*', branchcode => '*', article_requests => 'yes' } )->insert(); >+ok( $biblio->can_article_request($patron), 'Record is requestable with rule type yes' ); >+is( $biblio->article_request_type($patron), 'yes', 'Biblio article request type is yes' ); >+ok( $item->can_article_request($patron), 'Item is requestable with rule type yes' ); >+is( $item->article_request_type($patron), 'yes', 'Item article request type is yes' ); >+$rule->delete(); >+ >+$rule = $schema->resultset('Issuingrule') >+ ->new( { categorycode => '*', itemtype => '*', branchcode => '*', article_requests => 'bib_only' } )->insert(); >+ok( $biblio->can_article_request($patron), 'Record is requestable with rule type bib_only' ); >+is( $biblio->article_request_type($patron), 'bib_only', 'Biblio article request type is bib_only' ); >+ok( !$item->can_article_request($patron), 'Item is not requestable with rule type bib_only' ); >+is( $item->article_request_type($patron), 'bib_only', 'Item article request type is bib_only' ); >+$rule->delete(); >+ >+$rule = $schema->resultset('Issuingrule') >+ ->new( { categorycode => '*', itemtype => '*', branchcode => '*', article_requests => 'item_only' } )->insert(); >+ok( $biblio->can_article_request($patron), 'Record is requestable with rule type item_only' ); >+is( $biblio->article_request_type($patron), 'item_only', 'Biblio article request type is item_only' ); >+ok( $item->can_article_request($patron), 'Item is not requestable with rule type item_only' ); >+is( $item->article_request_type($patron), 'item_only', 'Item article request type is item_only' ); >+$rule->delete(); >+ >+$rule = $schema->resultset('Issuingrule') >+ ->new( { categorycode => '*', itemtype => '*', branchcode => '*', article_requests => 'no' } )->insert(); >+ok( !$biblio->can_article_request($patron), 'Record is requestable with rule type no' ); >+is( $biblio->article_request_type($patron), 'no', 'Biblio article request type is no' ); >+ok( !$item->can_article_request($patron), 'Item is not requestable with rule type no' ); >+is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); >+$rule->delete(); >+ >+$schema->storage->txn_rollback(); >-- >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 14610
:
42822
|
42823
|
42824
|
42825
|
42826
|
42827
|
42828
|
42829
|
43198
|
43199
|
43200
|
43201
|
43202
|
43264
|
43265
|
43266
|
43267
|
43268
|
43270
|
43271
|
43272
|
43273
|
43274
|
43278
|
43279
|
43280
|
43281
|
43282
|
43654
|
43655
|
43656
|
43657
|
43658
|
44219
|
44220
|
44221
|
44222
|
44223
|
44224
|
44225
|
44226
|
44227
|
44228
|
44229
|
44230
|
44231
|
44232
|
44233
|
44234
|
44235
|
44236
|
44237
|
44238
|
44239
|
44240
|
44241
|
44242
|
44916
|
44917
|
44918
|
44919
|
44920
|
44921
|
44922
|
44923
|
44924
|
44925
|
44926
|
45946
|
45947
|
45948
|
45949
|
45950
|
45951
|
45952
|
45953
|
45954
|
45955
|
45956
|
46518
|
46519
|
46520
|
46521
|
46522
|
46523
|
46524
|
46525
|
46526
|
46527
|
46528
|
46529
|
46530
|
46595
|
46596
|
46597
|
46598
|
46599
|
46600
|
46601
|
46602
|
46603
|
46604
|
46605
|
46606
|
46607
|
46608
|
46609
|
46610
|
46611
|
46612
|
47905
|
47906
|
47907
|
47908
|
47909
|
47910
|
47911
|
47912
|
47913
|
47914
|
47915
|
47916
|
47917
|
47918
|
47919
|
47920
|
47921
|
47922
|
48177
|
48178
|
48179
|
48180
|
48181
|
48182
|
48212
|
48213
|
48214
|
48215
|
48216
|
48217
|
48218
|
50348
|
50349
|
50350
|
50351
|
50352
|
50353
|
50354
|
51527
|
51528
|
51529
|
51530
|
51531
|
51532
|
51533
|
51534
|
51778
|
51779
|
51780
|
51781
|
51782
|
51783
|
52688
|
52689
|
52690
|
52691
|
52692
|
52693
|
55556
|
55557
|
55558
|
55559
|
55560
|
55561
|
55568
|
55569
|
56084
|
56085
|
56086
|
56087
|
56088
|
56089
|
56090
|
56318
|
56319
|
56320
|
56321
|
56322
|
56323
|
56324
|
56325
|
56326
|
56327
|
56328
|
56775
|
56776
|
56777
|
56778
|
56779
|
56780
|
56781
|
56782
|
56783
|
56784
|
56785
|
56816
|
56854
|
56855
|
56856
|
56857
|
56858
|
56859
|
56860
|
56861
|
56862
|
56863
|
56864
|
56865