Bugzilla – Attachment 66558 Details for
Bug 18635
Koha::Patron->guarantees() should return results alphabetically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18635 - Unit tests
Bug-18635---Unit-tests.patch (text/plain), 7.00 KB, created by
Nick Clemens (kidclamp)
on 2017-08-28 16:24:52 UTC
(
hide
)
Description:
Bug 18635 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-08-28 16:24:52 UTC
Size:
7.00 KB
patch
obsolete
>From 36e1b734803847ed25b43a739201e0008f35d046 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 18 May 2017 21:07:11 -0400 >Subject: [PATCH] Bug 18635 - Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >To test: >1 - Apply this patch only >2 - Prove t/db_dependent/Patron.t >3 - Tests fail >4 - Apply other patch >5 - Tests pass > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > t/db_dependent/Koha/Patrons.t | 55 +++++++++++++++++++++- > t/db_dependent/Patrons.t | 107 ------------------------------------------ > 2 files changed, 54 insertions(+), 108 deletions(-) > delete mode 100755 t/db_dependent/Patrons.t > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 41f6e33..d28fdde 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 22; >+use Test::More tests => 23; > use Test::Warn; > use Time::Fake; > use DateTime; >@@ -911,5 +911,58 @@ subtest 'account_locked' => sub { > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >+subtest 'Patron->guarantees' => sub { >+ plan tests => 5; >+ >+ my $builder = t::lib::TestBuilder->new; >+ >+ my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; >+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >+ >+ my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $guarantee1 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Zebra', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $guarantee2 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Yak', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $guarantee3 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Walrus', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $guarantee4 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Vulture', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $guarantee5 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Unicorn', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $guarantees = $guarantor->guarantees(); >+ >+ is( $guarantees->next()->borrowernumber, $guarantee5, "Return first guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $guarantee4, "Return second guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $guarantee3, "Return third guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $guarantee2, "Return fourth guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $guarantee1, "Return fifth guarantor alphabetically" ); >+ >+}; >+ > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/Patrons.t b/t/db_dependent/Patrons.t >deleted file mode 100755 >index a1c7ad9..0000000 >--- a/t/db_dependent/Patrons.t >+++ /dev/null >@@ -1,107 +0,0 @@ >-#!/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 Test::More tests => 17; >-use Test::Warn; >- >-use C4::Context; >-use Koha::Database; >-use Koha::DateUtils; >- >-use t::lib::TestBuilder; >- >-BEGIN { >- use_ok('Koha::Objects'); >- use_ok('Koha::Patrons'); >-} >- >-# Start transaction >-my $database = Koha::Database->new(); >-my $schema = $database->schema(); >-$schema->storage->txn_begin(); >-my $builder = t::lib::TestBuilder->new; >- >-my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; >-my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >- >-my $b1 = Koha::Patron->new( >- { >- surname => 'Test 1', >- branchcode => $branchcode, >- categorycode => $categorycode >- } >-); >-$b1->store(); >-my $now = dt_from_string; >-my $b2 = Koha::Patron->new( >- { >- surname => 'Test 2', >- branchcode => $branchcode, >- categorycode => $categorycode >- } >-); >-$b2->store(); >-my $three_days_ago = dt_from_string->add( days => -3 ); >-my $b3 = Koha::Patron->new( >- { >- surname => 'Test 3', >- branchcode => $branchcode, >- categorycode => $categorycode, >- updated_on => $three_days_ago, >- } >-); >-$b3->store(); >- >-my $b1_new = Koha::Patrons->find( $b1->borrowernumber() ); >-is( $b1->surname(), $b1_new->surname(), "Found matching patron" ); >-isnt( $b1_new->updated_on, undef, "borrowers.updated_on should be set" ); >-is( dt_from_string($b1_new->updated_on), $now, "borrowers.updated_on should have been set to now on creating" ); >- >-my $b3_new = Koha::Patrons->find( $b3->borrowernumber() ); >-is( dt_from_string($b3_new->updated_on), $three_days_ago, "borrowers.updated_on should have been kept to what we set on creating" ); >-$b3_new->set({ firstname => 'Some first name for Test 3' })->store(); >-$b3_new = Koha::Patrons->find( $b3->borrowernumber() ); >-is( dt_from_string($b3_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on updating" ); >- >-my @patrons = Koha::Patrons->search( { branchcode => $branchcode } ); >-is( @patrons, 3, "Found 3 patrons with Search" ); >- >-my $unexistent = Koha::Patrons->find( '1234567890' ); >-is( $unexistent, undef, 'Koha::Objects->Find should return undef if the record does not exist' ); >- >-my $patrons = Koha::Patrons->search( { branchcode => $branchcode } ); >-is( $patrons->count( { branchcode => $branchcode } ), 3, "Counted 3 patrons with Count" ); >- >-my $b = $patrons->next(); >-is( $b->surname(), 'Test 1', "Next returns first patron" ); >-$b = $patrons->next(); >-is( $b->surname(), 'Test 2', "Next returns second patron" ); >-$b = $patrons->next(); >-is( $b->surname(), 'Test 3', "Next returns third patron" ); >-$b = $patrons->next(); >-is( $b, undef, "Next returns undef" ); >- >-# Test Reset and iteration in concert >-$patrons->reset(); >-foreach my $b ( $patrons->as_list() ) { >- is( $b->categorycode(), $categorycode, "Iteration returns a patron object" ); >-} >- >-$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 18635
:
63552
|
63553
|
63558
|
63559
|
63617
|
66557
|
66558
|
77005
|
77006
|
77011
|
77012
|
77013
|
77435
|
77436