Bugzilla – Attachment 76922 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: Use more simple object for Object.t
Bug-20287-Use-more-simple-object-for-Objectt.patch (text/plain), 4.42 KB, created by
Jonathan Druart
on 2018-07-12 18:50:45 UTC
(
hide
)
Description:
Bug 20287: Use more simple object for Object.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-07-12 18:50:45 UTC
Size:
4.42 KB
patch
obsolete
>From a5bf3a4c56d93c5c369b6dfa726a31a6c24a3830 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 25 Jun 2018 12:53:19 -0300 >Subject: [PATCH] Bug 20287: Use more simple object for Object.t > >We initially use Koha::Patron to test Object.t, but now it overwrites >->store and so it is better to use a more simple object. >ApiKey has foreign keys and unique key. >We lost one test: there is only one unique key whereas we had 2 on >borrowers (I did not find a better option) > >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 | 65 +++++++++++++++----------------------------- > 1 file changed, 22 insertions(+), 43 deletions(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index d7e13cfbcd..b377e4b908 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -29,6 +29,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Libraries; > use Koha::Patrons; >+use Koha::ApiKeys; > > use Scalar::Util qw( isvstring ); > use Try::Tiny; >@@ -239,21 +240,24 @@ subtest "Test update method" => sub { > > subtest 'store() tests' => sub { > >- plan tests => 10; >+ plan tests => 7; >+ >+ # Using Koha::ApiKey to test Koha::Object>-store >+ # Simple object with foreign keys and unique key > > $schema->storage->txn_begin; > >- # Create a category to make sure its ID doesn't exist on the DB >- my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); >- my $category_id = $category->id; >- $category->delete; >+ # Create a patron to make sure its ID doesn't exist on the DB >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_id = $patron->id; >+ $patron->delete; > >- my $patron = Koha::Patron->new({ categorycode => $category_id }); >+ 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? > throws_ok >- { $patron->store } >+ { $api_key->store } > 'Koha::Exceptions::Object::FKConstraint', > 'Exception is thrown correctly'; > is( >@@ -263,45 +267,20 @@ subtest 'store() tests' => sub { > ); > is( > $@->broken_fk, >- 'categorycode', >+ 'patron_id', > 'Exception field is correct' > ); > >- my $library = $builder->build_object({ class => 'Koha::Libraries' }); >- $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); >- $patron = $builder->build_object({ class => 'Koha::Patrons' }); >- >- my $new_patron = Koha::Patron->new({ >- branchcode => $library->id, >- cardnumber => $patron->cardnumber, >- categorycode => $category->id >- }); >- >- throws_ok >- { $new_patron->store } >- 'Koha::Exceptions::Object::DuplicateID', >- 'Exception is thrown correctly'; >- >- is( >- $@->message, >- 'Duplicate ID', >- 'Exception message is correct' >- ); >- >- is( >- $@->duplicate_id, >- 'cardnumber', >- 'Exception field is correct' >- ); >+ $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ $api_key = $builder->build_object({ class => 'Koha::ApiKeys' }); > >- $new_patron = Koha::Patron->new({ >- branchcode => $library->id, >- userid => $patron->userid, >- categorycode => $category->id >+ my $new_api_key = Koha::ApiKey->new({ >+ patron_id => $patron_id, >+ secret => $api_key->secret, > }); > > throws_ok >- { $new_patron->store } >+ { $new_api_key->store } > 'Koha::Exceptions::Object::DuplicateID', > 'Exception is thrown correctly'; > >@@ -313,16 +292,16 @@ subtest 'store() tests' => sub { > > is( > $@->duplicate_id, >- 'userid', >+ 'secret', > 'Exception field is correct' > ); > > $schema->storage->dbh->{PrintError} = $print_error; > > # Successful test >- $patron->set({ firstname => 'Manuel' }); >- my $ret = $patron->store; >- is( ref($ret), 'Koha::Patron', 'store() returns the object on success' ); >+ $api_key->set({ secret => 'Manuel' }); >+ my $ret = $api_key->store; >+ is( ref($ret), 'Koha::ApiKey', 'store() returns the object on success' ); > > $schema->storage->txn_rollback; > }; >-- >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