Bugzilla – Attachment 125640 Details for
Bug 29083
Update article requests-related Koha::Patron methods to use relationships
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29083: Unit tests
Bug-29083-Unit-tests.patch (text/plain), 7.55 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-01 22:28:22 UTC
(
hide
)
Description:
Bug 29083: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-01 22:28:22 UTC
Size:
7.55 KB
patch
obsolete
>From 715a159c044b13ce35b8c205086a9e7b06a71cb9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Sep 2021 15:46:26 -0300 >Subject: [PATCH] Bug 29083: Unit tests > >This patch adds missing tests for Koha::Patron->article_requests and >moves (and extends) tests for 'article_requests_current' and >'article_requests_finished' that were originally in ArticleRequests.t >into Koha/Patron.t as we now do. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/ArticleRequests.t \ > t/db_dependent/Koha/Patron.t >=> SUCCESS: Tests pass! > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/ArticleRequests.t | 27 +------ > t/db_dependent/Koha/Patron.t | 119 ++++++++++++++++++++++++++++++- > 2 files changed, 120 insertions(+), 26 deletions(-) > >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >index 2313e1bc63..acc5704121 100644 >--- a/t/db_dependent/ArticleRequests.t >+++ b/t/db_dependent/ArticleRequests.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use POSIX qw(strftime); > >-use Test::More tests => 54; >+use Test::More tests => 45; > use Test::MockModule; > > use t::lib::TestBuilder; >@@ -110,30 +110,7 @@ is( $article_request->biblio->id, $biblio->id, '$ar->biblio() gets correspondi > is( $article_request->item->id, $item->id, '$ar->item() gets corresponding Koha::Item object' ); > is( $article_request->borrower->id, $patron->id, '$ar->borrower() gets corresponding Koha::Patron 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->set_pending(); >- >-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->set_pending(); >- >-$ar = $biblio->article_requests(); >+my $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' ); > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 0d62df241c..891107547a 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 13; > use Test::Exception; > use Test::Warn; > >@@ -883,3 +883,120 @@ subtest 'can_request_article() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'article_requests() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $article_requests = $patron->article_requests; >+ is( ref($article_requests), 'Koha::ArticleRequests', >+ 'In scalar context, type is correct' ); >+ is( $article_requests->count, 0, 'No article requests' ); >+ >+ foreach my $i ( 0 .. 3 ) { >+ >+ my $item = $builder->build_sample_item; >+ >+ Koha::ArticleRequest->new( >+ { >+ borrowernumber => $patron->id, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->id, >+ title => "Title", >+ } >+ )->request; >+ } >+ >+ $article_requests = $patron->article_requests; >+ is( $article_requests->count, 4, '4 article requests' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'article_requests_current() tests' => sub { >+ >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $item = $builder->build_sample_item; >+ >+ my $article_request = Koha::ArticleRequest->new( >+ { >+ borrowernumber => $patron->id, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, >+ title => "Boo", >+ } >+ )->request(); >+ >+ 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->set_pending(); >+ is( $patron->article_requests_current()->count(), >+ 1, 'Pending 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' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'article_requests_finished() tests' => sub { >+ >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $item = $builder->build_sample_item; >+ >+ my $article_request = Koha::ArticleRequest->new( >+ { >+ borrowernumber => $patron->id, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, >+ title => "Boo", >+ } >+ )->request(); >+ >+ 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_finished->count, >+ 0, 'Open request returned for article_requests_finished' ); >+ $article_request->set_pending(); >+ is( $patron->article_requests_finished->count, >+ 0, 'Pending 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(); >+ is( $patron->article_requests_finished->count, >+ 1, 'Completed request returned for article_requests_finished' ); >+ $article_request->cancel(); >+ is( $patron->article_requests_finished->count, >+ 1, 'Cancelled request not returned for article_requests_finished' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.33.0
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 29083
:
125160
|
125161
|
125162
|
125186
|
125240
|
125241
|
125242
|
125243
|
125268
|
125269
|
125270
|
125271
|
125640
|
125641
|
125642
|
125643
|
125833
|
125834
|
125835
|
125836
|
125837
|
125838
|
125840
|
125862