Bugzilla – Attachment 58526 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: Unit tests for Koha::Patron::Attribute->store
Bug-17828-Unit-tests-for-KohaPatronAttribute-store.patch (text/plain), 3.15 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-12-30 14:17:33 UTC
(
hide
)
Description:
Bug 17828: Unit tests for Koha::Patron::Attribute->store
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-12-30 14:17:33 UTC
Size:
3.15 KB
patch
obsolete
>From db4f434a3f04820546d0fd72df6c5370c07569c3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 30 Dec 2016 11:10:33 -0300 >Subject: [PATCH] Bug 17828: Unit tests for Koha::Patron::Attribute->store > >Unit tests for an overloaded Koha::Patron::Attribute->store that >checks attribute type's uniqueness property and raises an exception >conveniently. > >Test plan on the implementing patch. >--- > t/db_dependent/Koha/Patron/Attributes.t | 67 ++++++++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t >index 22e4d509a9..8e90637dc5 100644 >--- a/t/db_dependent/Koha/Patron/Attributes.t >+++ b/t/db_dependent/Koha/Patron/Attributes.t >@@ -19,16 +19,81 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use t::lib::TestBuilder; >+use Test::Exception; > > use Koha::Database; > use Koha::Patron::Attribute; >+use Koha::Patron::Attributes; > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >+subtest 'store() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron >+ = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >+ my $attribute_type_1 = $builder->build( >+ { source => 'BorrowerAttributeType', >+ value => { unique_id => 0 } >+ } >+ ); >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron, >+ code => $attribute_type_1->{code}, >+ attribute => 'Foo' >+ } >+ )->store; >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron, >+ code => $attribute_type_1->{code}, >+ attribute => 'Bar' >+ } >+ )->store; >+ my $attr_count >+ = Koha::Patron::Attributes->search( >+ { borrowernumber => $patron, code => $attribute_type_1->{code} } ) >+ ->count; >+ is( $attr_count, 2, >+ '2 non-unique attributes stored and retrieved correcctly' ); >+ >+ my $attribute_type_2 = $builder->build( >+ { source => 'BorrowerAttributeType', >+ value => { unique_id => 1 } >+ } >+ ); >+ >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron, >+ code => $attribute_type_2->{code}, >+ attribute => 'Foo' >+ } >+ )->store; >+ throws_ok { >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron, >+ code => $attribute_type_2->{code}, >+ attribute => 'Bar' >+ } >+ )->store; >+ } >+ 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint', >+ 'Exception thrown trying to store more than one unique attribute'; >+ my $attributes = Koha::Patron::Attributes->search( >+ { borrowernumber => $patron, code => $attribute_type_2->{code} } ); >+ is( $attributes->count, 1, '1 Unique attribute stored' ); >+ is( $attributes->next->attribute, >+ 'Foo', 'Unique attribute remains unchanged' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'opac_display() tests' => sub { > > plan tests => 2; >-- >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 17828
:
58526
|
58527
|
58557
|
58558
|
61505
|
61506
|
61547
|
61644
|
61662
|
61703
|
61704
|
61705
|
61706
|
61707
|
61708
|
61709