Bugzilla – Attachment 75791 Details for
Bug 20866
ArticleRequests.t fails on existing requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20866: Make ArticleRequests.t pass even if table is not empty
Bug-20866-Make-ArticleRequestst-pass-even-if-table.patch (text/plain), 3.73 KB, created by
Katrin Fischer
on 2018-06-04 19:33:36 UTC
(
hide
)
Description:
Bug 20866: Make ArticleRequests.t pass even if table is not empty
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-06-04 19:33:36 UTC
Size:
3.73 KB
patch
obsolete
>From c70e060d7bdfb81b541f6acb7946b6a43f8b116c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 4 Jun 2018 15:28:02 -0300 >Subject: [PATCH] Bug 20866: Make ArticleRequests.t pass even if table is not > empty > >Previous patch from Marcel removed the data from article_requests, I do >not think it is a good idea to remove existing data, it could hide bugs. > >This patch moves the count inside the subtest block in order to have the >correct value when these tests are executed. >Previous code was broken: Koha::Patron->store does not generate a >userid, and ->search_limited did not work correctly >(Koha::Patron->has_permission returned early because of the non-existing >userid, 'return unless $self->userid;'); > >Test plan: >[1] Create an article request. >[2] Run t/db_dependent/ArticleRequests.t > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/ArticleRequests.t | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >index 7c99657..cc43185 100755 >--- a/t/db_dependent/ArticleRequests.t >+++ b/t/db_dependent/ArticleRequests.t >@@ -72,14 +72,13 @@ my $patron = Koha::Patron->new( > categorycode => $category->{categorycode}, > branchcode => $branch->{branchcode}, > flags => 1,# superlibrarian >+ userid => 'a_userid_for_tests', # So far Koha::Patron->store does not deal with userid, see bug 20287 > } > )->store(); > ok( $patron->id, 'Koha::Patron created' ); > my $patron_2 = $builder->build({ source => 'Borrower', value => { flags => 0 } }); > $patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); > >-my $nb_article_requests = Koha::ArticleRequests->count; >- > # store > Koha::Notice::Messages->delete; > my $article_request_title = 'an article request title'; >@@ -207,16 +206,18 @@ $rule->delete(); > subtest 'search_limited' => sub { > plan tests => 4; > C4::Context->_new_userenv('xxx'); >+ my $nb_article_requests = Koha::ArticleRequests->count; >+ > my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store; > my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store; > Koha::Library::Group->new({ parent_id => $group_1->id, branchcode => $patron->branchcode })->store(); > Koha::Library::Group->new({ parent_id => $group_2->id, branchcode => $patron_2->branchcode })->store(); > set_logged_in_user( $patron ); # Is superlibrarian >- is( Koha::ArticleRequests->count, $nb_article_requests + 1, 'Koha::ArticleRequests should return all article requests' ); >- is( Koha::ArticleRequests->search_limited->count, $nb_article_requests + 1, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' ); >+ is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' ); >+ is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' ); > set_logged_in_user( $patron_2 ); # Is restricted >- is( Koha::ArticleRequests->count, $nb_article_requests + 1, 'Koha::ArticleRequests should return all article requests' ); >- is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' ); >+ is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' ); >+ is( Koha::ArticleRequests->search_limited->count, 0, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' ); > }; > > $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 20866
:
75750
|
75784
|
75791
|
75813
|
75814