Bugzilla – Attachment 61707 Details for
Bug 17828
Koha::Patron::Attribute->store should raise an exception if unique_id is being broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17828: (QA followup) Add ->type and reuse it
Bug-17828-QA-followup-Add--type-and-reuse-it.patch (text/plain), 3.43 KB, created by
Jonathan Druart
on 2017-03-29 19:49:45 UTC
(
hide
)
Description:
Bug 17828: (QA followup) Add ->type and reuse it
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-03-29 19:49:45 UTC
Size:
3.43 KB
patch
obsolete
>From 025451302424b6739dcce48c89e1e1e281aab52f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 27 Mar 2017 12:47:14 -0300 >Subject: [PATCH] Bug 17828: (QA followup) Add ->type and reuse it > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Patron/Attribute.pm | 19 +++++++++++++-- > t/db_dependent/Koha/Patron/Attributes.t | 42 ++++++++++++++++++++++++++++++++- > 2 files changed, 58 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index fe62dfa..52eb9c1 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -79,6 +79,21 @@ sub opac_editable { > return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable; > } > >+=head3 type >+ >+ my $attribute_type = $attribute->type; >+ >+Returns a C<Koha::Patron::Attribute::Type> object corresponding to the current patron attribute >+ >+=cut >+ >+sub type { >+ >+ my $self = shift; >+ >+ return Koha::Patron::Attribute::Types->find( $self->code ); >+} >+ > =head2 Internal methods > > =head3 _check_repeatable >@@ -93,7 +108,7 @@ sub _check_repeatable { > > my $self = shift; > >- if ( !Koha::Patron::Attribute::Types->find( $self->code )->repeatable ) { >+ if ( !$self->type->repeatable ) { > my $attr_count > = Koha::Database->new->schema->resultset( $self->_type )->search( > { borrowernumber => $self->borrowernumber, >@@ -119,7 +134,7 @@ sub _check_unique_id { > > my $self = shift; > >- if ( Koha::Patron::Attribute::Types->find( $self->code )->unique_id ) { >+ if ( $self->type->unique_id ) { > my $unique_count > = Koha::Database->new->schema->resultset( $self->_type ) > ->search( { code => $self->code, attribute => $self->attribute } ) >diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t >index 36b04df..cbb02b9 100644 >--- a/t/db_dependent/Koha/Patron/Attributes.t >+++ b/t/db_dependent/Koha/Patron/Attributes.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > > use t::lib::TestBuilder; > use Test::Exception; >@@ -235,4 +235,44 @@ subtest 'opac_editable() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'type() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron >+ = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >+ my $attr_type = $builder->build( { source => 'BorrowerAttributeType' } ); >+ my $attribute = Koha::Patron::Attribute->new( >+ { borrowernumber => $patron, >+ code => $attr_type->{code}, >+ attribute => $patron >+ } >+ ); >+ >+ my $attribute_type = $attribute->type; >+ >+ is( ref($attribute_type), >+ 'Koha::Patron::Attribute::Type', >+ '->type returns a Koha::Patron::Attribute::Type object' >+ ); >+ >+ is( $attribute_type->code, >+ $attr_type->{code}, >+ '->type returns the right Koha::Patron::Attribute::Type object' ); >+ >+ is( $attribute_type->opac_editable, >+ $attr_type->{opac_editable}, >+ '->type returns the right Koha::Patron::Attribute::Type object' >+ ); >+ >+ is( $attribute_type->opac_display, >+ $attr_type->{opac_display}, >+ '->type returns the right Koha::Patron::Attribute::Type object' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > 1; >-- >2.9.3
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 17828
:
58526
|
58527
|
58557
|
58558
|
61505
|
61506
|
61547
|
61644
|
61662
|
61703
|
61704
|
61705
|
61706
| 61707 |
61708
|
61709