Bugzilla – Attachment 101122 Details for
Bug 20443
Move C4::Members::Attributes to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20443: Revert some stuffs from 12159
Bug-20443-Revert-some-stuffs-from-12159.patch (text/plain), 7.37 KB, created by
Jonathan Druart
on 2020-03-20 14:46:57 UTC
(
hide
)
Description:
Bug 20443: Revert some stuffs from 12159
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 14:46:57 UTC
Size:
7.37 KB
patch
obsolete
>From e1294c9ccf7ee863c7150eeb48401645c21d3c9d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 13 Jul 2018 10:41:15 -0300 >Subject: [PATCH] Bug 20443: Revert some stuffs from 12159 > >These methods have been added to Koha::Patron::Attribute but are wrong, see bug 18339 > >We should use ->type->$method instead > >Moreover the tests exist in another subtest, we do not need them. > >Signed-off-by: Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 51 ------------------- > Koha/Schema/Result/BorrowerAttribute.pm | 15 ++++++ > t/db_dependent/Koha/Patron/Attributes.t | 65 +------------------------ > t/db_dependent/Koha/Patrons.t | 49 ------------------- > 4 files changed, 16 insertions(+), 164 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index 1dd98242d1..03bfd91550 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -80,57 +80,6 @@ sub opac_editable { > return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable; > } > >-=head3 display_checkout >- >- my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); >- if ( $attribute->display_checkout ) { ... } >- >-=cut >- >-sub display_checkout { >- >- my $self = shift; >- >- return $self->type->display_checkout; >-} >- >-=head3 value_description >- >- my $description = $attribute->value_description >- >- Return authorised value description or free text based on attribute type settings >- >-=cut >- >-sub value_description { >- >- my $self = shift; >- >- if ( $self->type->authorised_value_category ) { >- my $av = Koha::AuthorisedValues->search({ >- category => $self->type->authorised_value_category, >- authorised_value => $self->attribute, >- }); >- return $av->next->lib if $av->count; >- } >- return $self->attribute; >-} >- >-=head3 type_description >- >- my $description = $attribute->type_description >- >- Return description of attribute type >- >-=cut >- >-sub type_description { >- >- my $self = shift; >- >- return $self->type->description; >-} >- > =head3 type > > my $attribute_type = $attribute->type; >diff --git a/Koha/Schema/Result/BorrowerAttribute.pm b/Koha/Schema/Result/BorrowerAttribute.pm >index 2dc8268c15..2a8398ad68 100644 >--- a/Koha/Schema/Result/BorrowerAttribute.pm >+++ b/Koha/Schema/Result/BorrowerAttribute.pm >@@ -109,6 +109,21 @@ __PACKAGE__->belongs_to( > # Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-08 04:41:27 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EarETnedFsmRmAAJAUrKGg > >+=head2 borrower_attribute_types >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::BorrowerAttributeType> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "borrower_attribute_types", >+ "Koha::Schema::Result::BorrowerAttributeType", >+ { "foreign.code" => "self.code" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },); >+ >+ > sub koha_object_class { > 'Koha::Patron::Attribute'; > } >diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t >index 99eaecef39..fbe1190e62 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 => 7; >+use Test::More tests => 3; > > use t::lib::TestBuilder; > use Test::Exception; >@@ -274,66 +274,3 @@ subtest 'type() tests' => sub { > > $schema->storage->txn_rollback; > }; >- >-subtest 'display_checkout() tests' => sub { >- >- plan tests => 2; >- >- $schema->storage->txn_begin; >- >- my $patron = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >- my $attribute_type_1 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { display_checkout => 1 } >- } >- ); >- >- my $attribute_1 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_1->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_1->display_checkout, 1, '->display_checkout returns 1' ); >- >- my $attribute_type_2 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { display_checkout => 0 } >- } >- ); >- >- my $attribute_2 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_2->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_2->display_checkout, 0, '->display_checkout returns 0' ); >- >- $schema->storage->txn_rollback; >-}; >- >-subtest 'type_description() and value_description tests' => sub { >- >- plan tests => 2; >- >- $schema->storage->txn_begin; >- >- my $patron = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >- my $attribute_type_1 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { description => "Type 1" } >- } >- ); >- >- my $attribute_1 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_1->{code}, >- attribute => "Attribute 1" >- } >- ); >- is( $attribute_1->type_description, "Type 1" , '->type_description returns right value' ); >- is( $attribute_1->value_description, "Attribute 1" , '->value_description returns right value' ); >- >- $schema->storage->txn_rollback; >-}; >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 6e9926c2db..662b8524db 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1641,55 +1641,6 @@ subtest 'generate_userid' => sub { > $patron_2->delete; > }; > >-subtest 'attributes' => sub { >- plan tests => 2; >- >- my $library1 = Koha::Library->new({ >- branchcode => 'LIBPATRON', >- branchname => 'Library of testing patron', >- })->store; >- >- my $library2 = Koha::Library->new({ >- branchcode => 'LIBATTR', >- branchname => 'Library for testing attribute', >- })->store; >- >- my $category = Koha::Patron::Category->new({ >- categorycode => 'CAT1', >- description => 'Category 1', >- })->store; >- >- my $patron = Koha::Patron->new({ >- firstname => 'Patron', >- surname => 'with attributes', >- branchcode => 'LIBPATRON', >- categorycode => 'CAT1', >- })->store; >- >- my $attribute_type1 = Koha::Patron::Attribute::Type->new({ >- code => 'CODE_A', >- description => 'Code A desciption', >- })->store; >- >- my $attribute_type2 = Koha::Patron::Attribute::Type->new({ >- code => 'CODE_B', >- description => 'Code A desciption', >- })->store; >- >- $attribute_type2->library_limits ( [ $library2->branchcode ] ); >- >- Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type1->code, attribute => 'value 1' } )->store(); >- Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type2->code, attribute => 'value 2' } )->store(); >- >- is( $patron->attributes->count, 1, 'There should be one attribute'); >- >- $attribute_type2->library_limits ( [ $library1->branchcode ] ); >- >- is( $patron->attributes->count, 2, 'There should be 2 attributes'); >- >- $patron->delete; >-}; >- > $nb_of_patrons = Koha::Patrons->search->count; > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' ); >-- >2.20.1
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 20443
:
101122
|
101123
|
101124
|
101125
|
101126
|
101127
|
101128
|
101129
|
101130
|
101131
|
101132
|
101133
|
101134
|
101135
|
101136
|
101137
|
101138
|
101139
|
101140
|
101141
|
101142
|
101143
|
101144
|
101145
|
101146
|
101147
|
101148
|
101149
|
101150
|
101209
|
101210
|
101211
|
101212
|
101213
|
101214
|
101215
|
101216
|
101217
|
101218
|
101219
|
101220
|
101221
|
101222
|
101223
|
101224
|
101225
|
101226
|
101227
|
101228
|
101229
|
101230
|
101231
|
101232
|
101233
|
101234
|
101235
|
101236
|
101237
|
101472
|
104519