From 8b229996c390b90193ef7437d338a9ce4355de41 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 20 Dec 2017 16:19:07 -0300 Subject: [PATCH] Bug 19841: Unit tests This patch introduces unit tests for the new behaviour of AddMember (raising an exception if the passed categorycode is not valid. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Members.t => FAIL: It should fail because the feature is still not implemented. Signed-off-by: Josef Moravec --- t/db_dependent/Members.t | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index a933827..cfb314f 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -17,8 +17,10 @@ use Modern::Perl; -use Test::More tests => 63; +use Test::More tests => 64; use Test::MockModule; +use Test::Exception; + use Data::Dumper qw/Dumper/; use C4::Context; use Koha::Database; @@ -501,3 +503,25 @@ subtest 'Trivial test for AddMember_Auto' => sub { }; $schema->storage->txn_rollback; + +subtest 'AddMember (invalid categorycode) tests' => sub { + plan tests => 1; + + $schema->storage->txn_begin; + + my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); + my $category_id = $category->id; + # Remove category to make sure the id is not on the DB + $category->delete; + + my $patron_data = { + categorycode => $category_id + }; + + throws_ok + { AddMember( %{ $patron_data } ); } + 'Koha::Exceptions::BadParameter', + 'AddMember raises an exception on invalid categorycode'; + + $schema->storage->txn_rollback; +}; -- 2.1.4