Bugzilla – Attachment 76923 Details for
Bug 20287
Move AddMember and ModMember to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20287: Test exception DuplicateID for Koha::Patron->store
Bug-20287-Test-exception-DuplicateID-for-KohaPatro.patch (text/plain), 3.31 KB, created by
Jonathan Druart
on 2018-07-12 18:50:51 UTC
(
hide
)
Description:
Bug 20287: Test exception DuplicateID for Koha::Patron->store
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-07-12 18:50:51 UTC
Size:
3.31 KB
patch
obsolete
>From 1d3ce290a953d67c0b057901f74a18688e4967e8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 25 Jun 2018 13:14:05 -0300 >Subject: [PATCH] Bug 20287: Test exception DuplicateID for Koha::Patron->store > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Object.t | 2 +- > t/db_dependent/Koha/Patrons.t | 24 +++++++++++++++++++++++- > t/db_dependent/Members.t | 3 +++ > 3 files changed, 27 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index b377e4b908..abb0d740ad 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -255,7 +255,7 @@ subtest 'store() tests' => sub { > my $api_key = Koha::ApiKey->new({ patron_id => $patron_id }); > > my $print_error = $schema->storage->dbh->{PrintError}; >- $schema->storage->dbh->{PrintError} = 0; # FIXME This does not longer work - because of the transaction in Koha::Patron->store? >+ $schema->storage->dbh->{PrintError} = 0; > throws_ok > { $api_key->store } > 'Koha::Exceptions::Object::FKConstraint', >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index fa3c8dd43a..960b55c9c5 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,8 +19,9 @@ > > use Modern::Perl; > >-use Test::More tests => 31; >+use Test::More tests => 32; > use Test::Warn; >+use Test::Exception; > use Time::Fake; > use DateTime; > use JSON; >@@ -1425,6 +1426,27 @@ subtest 'Test Koha::Patrons::merge' => sub { > $schema->storage->txn_rollback; > }; > >+subtest '->store' => sub { >+ plan tests => 1; >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ >+ my $print_error = $schema->storage->dbh->{PrintError}; >+ $schema->storage->dbh->{PrintError} = 0; ; # FIXME This does not longer work - because of the transaction in Koha::Patron->store? >+ >+ my $patron_1 = $builder->build_object({class=> 'Koha::Patrons'}); >+ my $patron_2 = $builder->build_object({class=> 'Koha::Patrons'}); >+ >+ throws_ok >+ { $patron_2->userid($patron_1->userid)->store; } >+ 'Koha::Exceptions::Object::DuplicateID', >+ 'AddMember raises an exception on invalid categorycode'; >+ >+ $schema->storage->dbh->{PrintError} = $print_error; >+ $schema->storage->txn_rollback; >+}; >+ >+ > # TODO Move to t::lib::Mocks and reuse it! > sub set_logged_in_user { > my ($patron) = @_; >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index b9a2e3fccf..b878afbfed 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -176,6 +176,8 @@ is( $borrower->{dateenrolled}, '2015-09-06', 'Koha::Patron->store should correct > subtest 'Koha::Patron->store should not update userid if not true' => sub { > plan tests => 3; > >+ # TODO Move this to t/db_dependent/Koha/Patrons.t subtest ->store >+ > $data{ cardnumber } = "234567890"; > $data{userid} = 'a_user_id'; > $borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; >@@ -382,6 +384,7 @@ $schema->storage->txn_rollback; > > subtest 'Koha::Patron->store (invalid categorycode) tests' => sub { > plan tests => 1; >+ # TODO Move this to t/db_dependent/Koha/Patrons.t subtest ->store > > $schema->storage->txn_begin; > >-- >2.11.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 20287
:
73436
|
76901
|
76902
|
76903
|
76904
|
76905
|
76906
|
76907
|
76908
|
76909
|
76910
|
76911
|
76912
|
76913
|
76914
|
76915
|
76916
|
76917
|
76918
|
76919
|
76920
|
76921
|
76922
| 76923 |
76924
|
76927
|
77221