From d15ba28a28bfd341752735aa8abed4a59513b21f Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 23 Jun 2016 21:08:00 -0400 Subject: [PATCH] Bug 17793: Test Cases There was no form of testing for the change. In order to test the perl-side of the changes, I just went to a variety of URLs to see if they have the expected three tabs. TEST PLAN --------- 1) Apply this patch 2) At the bash prompt, export KOHA_INTRANET_URL=http://localhost:8080/ -- Or whatever yours is. With or without the trailing / 3) prove -v t/db_dependent/www/prefs-admin_search.t -- before applying the other patch, there should be failures. 4) Apply both patches 5) prove -v t/db_dependent/www/prefs-admin_search.t -- there should be no failures now. 6) run koha qa test tools Signed-off-by: Mark Tompsett https://bugs.koha-community.org/show_bug.cgi?id=17864 --- t/db_dependent/www/prefs-admin_search.t | 107 ++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 t/db_dependent/www/prefs-admin_search.t diff --git a/t/db_dependent/www/prefs-admin_search.t b/t/db_dependent/www/prefs-admin_search.t new file mode 100644 index 0000000..1f3f9d2 --- /dev/null +++ b/t/db_dependent/www/prefs-admin_search.t @@ -0,0 +1,107 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2016 Mark Tompsett +# +# 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; +use Test::WWW::Mechanize; +use XML::Simple; + +my $koha_conf = $ENV{KOHA_CONF}; +my $xml = XMLin($koha_conf); + +my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; +my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; +my $intranet = $ENV{KOHA_INTRANET_URL}; + +# test KOHA_INTRANET_URL is set +if ( not defined $intranet ) { + plan skip_all => + "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; +} + +$intranet =~ s/\/$//xsm; + +test_prefs_admin_search(); + +done_testing(); + +sub test_prefs_admin_search { + + my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); + + $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", + 'connect to intranet' ); + $agent->form_name('loginform'); + $agent->field( 'password', $password ); + $agent->field( 'userid', $user ); + $agent->field( 'branch', q{} ); + $agent->click_ok( q{}, 'login to staff client' ); + + $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); + + my $base_url = "$intranet/cgi-bin/koha/admin"; + note "Base URL: $base_url\n"; + my @test_urls = ( + 'admin-home.pl', + 'audio_alerts.pl', + 'authtypes.pl', + 'auth_tag_structure.pl', + 'authorised_values.pl', + 'biblio_framework.pl', + 'marctagstructure.pl', + 'branch_transfer_limits.pl', + 'branches.pl', + 'checkmarc.pl', + 'classsources.pl', + 'columns_settings.pl', + 'didyoumean.pl', + 'edi_accounts.pl', + 'edi_ean_accounts.pl', + 'fieldmapping.pl', + 'item_circulation_alerts.pl', + 'items_search_fields.pl', + 'items_search_field.pl', + 'itemtypes.pl', + 'koha2marclinks.pl', + 'matching-rules.pl', + 'oai_sets.pl', + 'oai_set_mappings.pl', + 'patron-attr-types.pl', + 'smart-rules.pl', + 'transport-cost-matrix.pl', + 'sms_providers.pl', + ); + + foreach my $test_url (@test_urls) { + my $current_url = $base_url . q{/} . $test_url; + eval { + $agent->get_ok( $current_url, 'Checking ' . $test_url ); + $agent->content_contains('#syspref_search','Expecting #syspref_search'); + $agent->content_contains('#circ_search','Expecting #circ_search'); + $agent->content_contains('#catalog_search','Expecting #catalog_search'); + $agent->content_lacks('#checkin_search','Expecting no #checkin_search'); + $agent->content_lacks('#renew_search','Expecting no #renew_search'); + } || fail('Checking ' . $test_url . ' failed!'); + } + + return; +} + +1; -- 2.1.4