From f4a8196e9a417d5e7605154b1a6590fc2419bd53 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 4 Sep 2017 09:19:01 +0200 Subject: [PATCH] Bug 18811: [QA Follow-up] Add tests for Koha::Authority::Subfields/Tags Content-Type: text/plain; charset=utf-8 Renaming t/db_dependent/Authorities to Authority Adding Subfields.t and Tags.t Test plan: [1] prove t/db_dependent/Authority Signed-off-by: Marcel de Rooy --- t/db_dependent/{Authorities => Authority}/Merge.t | 0 .../{Authorities => Authority}/MergeRequests.t | 0 t/db_dependent/Authority/Subfields.t | 49 ++++++++++++++++++++++ t/db_dependent/Authority/Tags.t | 48 +++++++++++++++++++++ 4 files changed, 97 insertions(+) rename t/db_dependent/{Authorities => Authority}/Merge.t (100%) rename t/db_dependent/{Authorities => Authority}/MergeRequests.t (100%) create mode 100644 t/db_dependent/Authority/Subfields.t create mode 100644 t/db_dependent/Authority/Tags.t diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authority/Merge.t similarity index 100% rename from t/db_dependent/Authorities/Merge.t rename to t/db_dependent/Authority/Merge.t diff --git a/t/db_dependent/Authorities/MergeRequests.t b/t/db_dependent/Authority/MergeRequests.t similarity index 100% rename from t/db_dependent/Authorities/MergeRequests.t rename to t/db_dependent/Authority/MergeRequests.t diff --git a/t/db_dependent/Authority/Subfields.t b/t/db_dependent/Authority/Subfields.t new file mode 100644 index 0000000..dc5e53a --- /dev/null +++ b/t/db_dependent/Authority/Subfields.t @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Copyright 2017 Koha Development team +# +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; + +use t::lib::TestBuilder; + +use Koha::Authority::Subfields; +use Koha::Database; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; + +subtest "Some supertrivial tests for Subfield" => sub { + plan tests => 3; + my $authtype = t::lib::TestBuilder->new->build({ + source => 'AuthType' + }); + my $cnt = Koha::Authority::Subfields->count; + my $rec = Koha::Authority::Subfield->new({ + authtypecode => $authtype->{authtypecode}, + tagfield => '100', + tagsubfield => 'a', + })->store; + is( Koha::Authority::Subfields->count, $cnt + 1, 'One record added' ); + $rec->update({ liblibrarian => 'intelligent text' }); + is( Koha::Authority::Subfields->find( $authtype->{authtypecode}, '100', 'a' )->liblibrarian, 'intelligent text', 'Found record' ); + $rec->delete; + is( Koha::Authority::Subfields->count, $cnt, 'One record deleted' ); +}; + +$schema->storage->txn_rollback; diff --git a/t/db_dependent/Authority/Tags.t b/t/db_dependent/Authority/Tags.t new file mode 100644 index 0000000..4111f7a --- /dev/null +++ b/t/db_dependent/Authority/Tags.t @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# Copyright 2017 Koha Development team +# +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; + +use t::lib::TestBuilder; + +use Koha::Authority::Tags; +use Koha::Database; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; + +subtest "Some supertrivial tests for Tag" => sub { + plan tests => 3; + my $authtype = t::lib::TestBuilder->new->build({ + source => 'AuthType' + }); + my $cnt = Koha::Authority::Tags->count; + my $rec = Koha::Authority::Tag->new({ + authtypecode => $authtype->{authtypecode}, + tagfield => '100', + })->store; + is( Koha::Authority::Tags->count, $cnt + 1, 'One record added' ); + $rec->update({ liblibrarian => 'another intelligent idea' }); + is( Koha::Authority::Tags->find( $authtype->{authtypecode}, '100' )->liblibrarian, 'another intelligent idea', 'Found record' ); + $rec->delete; + is( Koha::Authority::Tags->count, $cnt, 'One record deleted' ); +}; + +$schema->storage->txn_rollback; -- 2.1.4