Bugzilla – Attachment 74782 Details for
Bug 12159
Duplicate borrower_add_additional_fields function
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12159: Add tests
Bug-12159-Add-tests.patch (text/plain), 4.96 KB, created by
Josef Moravec
on 2018-04-24 07:57:58 UTC
(
hide
)
Description:
Bug 12159: Add tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-04-24 07:57:58 UTC
Size:
4.96 KB
patch
obsolete
>From b35cb108d7e0baf6dcdb2be64d604bdde74d9c96 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Fri, 16 Mar 2018 11:03:23 +0000 >Subject: [PATCH] Bug 12159: Add tests > >Test plan: >prove t/db_dependent/Koha/Patron/Attributes.t t/db_dependent/Koha/Patrons.t >--- > t/db_dependent/Koha/Patron/Attributes.t | 64 ++++++++++++++++++++++++++++++++- > t/db_dependent/Koha/Patrons.t | 50 +++++++++++++++++++++++++- > 2 files changed, 112 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t >index 044f317..99eaece 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 => 5; >+use Test::More tests => 7; > > use t::lib::TestBuilder; > use Test::Exception; >@@ -275,3 +275,65 @@ 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 bb6e2bc..56b1f6e 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 => 31; >+use Test::More tests => 32; > use Test::Warn; > use Time::Fake; > use DateTime; >@@ -1356,6 +1356,54 @@ 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; >+}; > > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); >-- >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 12159
:
72902
|
73018
|
73019
|
74781
|
74782
|
74791
|
74792
|
75811
|
75812
|
75822
|
76945
|
76946
|
76947
|
77050
|
77051
|
77052
|
86166
|
86167
|
86168
|
86882
|
86883
|
86884
|
86885