Bugzilla – Attachment 59173 Details for
Bug 17934
Various issues with auth_values_input_www.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17934: Make t/db_dependent/www/auth_values_input_www.t awesome
Bug-17934-Make-tdbdependentwwwauthvaluesinputwwwt-.patch (text/plain), 12.27 KB, created by
Mark Tompsett
on 2017-01-18 18:30:56 UTC
(
hide
)
Description:
Bug 17934: Make t/db_dependent/www/auth_values_input_www.t awesome
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2017-01-18 18:30:56 UTC
Size:
12.27 KB
patch
obsolete
>From 72ed436f5276d4e62eb5afd4a801fa704216dc8e Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 18 Jan 2017 15:38:31 +0000 >Subject: [PATCH] Bug 17934: Make t/db_dependent/www/auth_values_input_www.t > awesome > >There were two lines of code which declared unused variables. >They were removed. Next, the issue of double planning encountered >on bug 17540 >(https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17540#c3) >was encountered. So this corrects that and adds a little more >error handling into the whole C4::Context using process so that >perlcritic -4 is achieved. >Also typo on Korean in a comment. > >TEST PLAN >--------- >2) follow these commands: > >$ mv C4/Context.pm C4/Context_backup.pm >$ sudo koha-shell -c "prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- Nasty fail > >$ mv C4/Context_backup.pm C4/Context.pm >$ sudo koha-shell -c "export PERL5LIB=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- Nasty fail > >$ sudo koha-shell -c "export KOHA_CONF=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- Nasty fail > >$ sudo koha-shell -c "export KOHA_INTRANET_URL=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >$ sudo koha-shell -c "prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- Nasty fail > >$ sudo koha-shell -c "export KOHA_INTRANET_URL=\"http://localhost:8080/\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- This should work. > >$ perlcritic -4 t/db_dependent/www/auth_values_input_www.t >-- This should be OK > >2) apply patch >3) follow these commands: > >$ mv C4/Context.pm C4/Context_backup.pm >$ sudo koha-shell -c "prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- This should trigger the C4::Context not working message > >$ mv C4/Context_backup.pm C4/Context.pm >$ sudo koha-shell -c "export PERL5LIB=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- This should trigger the C4::Contxt not loading message > >$ sudo koha-shell -c "export KOHA_CONF=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- This should trigger the KOHA_CONF not set message > >$ sudo koha-shell -c "export KOHA_INTRANET_URL=\"\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >$ sudo koha-shell -c "prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- These should both trigger the KOHA_INTRANET_URL not set message > >$ sudo koha-shell -c "export KOHA_INTRANET_URL=\"http://localhost:8080/\";prove t/db_dependent/www/auth_values_input_www.t" kohadev >-- This should work. > >$ perlcritic -4 t/db_dependent/www/auth_values_input_www.t >-- This should be OK >3) run koha qa test tools >--- > t/db_dependent/www/auth_values_input_www.t | 106 ++++++++++++++++------------- > 1 file changed, 58 insertions(+), 48 deletions(-) > >diff --git a/t/db_dependent/www/auth_values_input_www.t b/t/db_dependent/www/auth_values_input_www.t >index 265865c..d0a3c93 100644 >--- a/t/db_dependent/www/auth_values_input_www.t >+++ b/t/db_dependent/www/auth_values_input_www.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use utf8; >-use Test::More tests => 33; >+use Test::More tests => 34; > use Test::WWW::Mechanize; > use XML::Simple; > use JSON; >@@ -27,47 +27,57 @@ use File::Spec; > use POSIX; > use URI::Escape; > use Encode; >+use Carp; >+use Module::Load::Conditional qw/check_install can_load/; > >-my $testdir = File::Spec->rel2abs( dirname(__FILE__) ); >+my $skip_all = q{}; >+if ( ! check_install( module => 'C4::Context' ) ) { >+ $skip_all = "Tests skipped. You must have a working C4::Context.\n"; >+} >+elsif ( ! can_load( modules => { 'C4::Context' => undef } ) ) { >+ $skip_all = "Tests skipped. You must be able to load C4::Context.\n"; >+} > > my $koha_conf = $ENV{KOHA_CONF}; >-my $xml = XMLin($koha_conf); >- >-eval{ >- use C4::Context; >-}; >-if ($@) { >- plan skip_all => "Tests skip. You must have a working Context\n"; >+my ($xml, $user, $password); >+if ($koha_conf) { >+ $xml = XMLin($koha_conf); >+ $user = $ENV{KOHA_USER} || $xml->{config}->{user}; >+ $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; >+} >+elsif ($skip_all eq q{}) { >+ $skip_all = "Tests skipped. You must set env. variable KOHA_CONF to run tests.\n"; > } > >-my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; >-my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; > my $intranet = $ENV{KOHA_INTRANET_URL}; > >-if (not defined $intranet) { >- plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; >+if ($skip_all eq q{} && ! $intranet) { >+ $skip_all = "Tests skipped. You must set env. variable KOHA_INTRANET_URL to run tests\n"; > } > >+if (length $skip_all > 0) { >+ croak $skip_all; # to keep Test Summary output >+} >+ >+use_ok('C4::Context'); > my $dbh = C4::Context->dbh; > >-$intranet =~ s#/$##; >+$intranet =~ s/\/$//xsm; > > my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); >-my $jsonresponse; > my ($category, $expected_base, $add_form_link_exists, $delete_form_link_exists); > > # -------------------------------------------------- LOGIN > >- > $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', '' ); >-$agent->click_ok( '', 'login to staff client' ); >+$agent->field( 'branch', q{} ); >+$agent->click_ok( q{}, 'login to staff client' ); > $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); > >-#--------------------------------------------------- Test with corean and greek chars >+#--------------------------------------------------- Test with Korean and greek chars > > $category = 'å¦åä¼Î¼Î¼'; > $dbh->do(q|DELETE FROM authorised_values WHERE category = ?|, undef, $category); >@@ -78,12 +88,12 @@ $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' ); > $agent->form_name('Aform'); > $agent->field('category', $category); >-$agent->click_ok( '', "Create new AV category " ); >+$agent->click_ok( q{}, 'Create new AV category ' ); > >-$agent->base_like(qr|$expected_base|, "check base"); >+$agent->base_like(qr/$expected_base/xsm, 'check base'); > $add_form_link_exists = 0; > for my $link ( $agent->links() ) { >- if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) { >+ if ( $link->url =~ m/authorised_values.pl\x3Fop=add_form&category=$category/xsm ) { > $add_form_link_exists = 1; > } > } >@@ -94,34 +104,34 @@ $agent->form_name('Aform'); > $agent->field('authorised_value', 'εÏιμεq'); > $agent->field('lib_opac', 'autdesc2'); > $agent->field('lib', 'desc1'); >-$agent->field('branches', ''); >-$agent->click_ok( '', "Create a new value for the category" ); >+$agent->field('branches', q{}); >+$agent->click_ok( q{}, 'Create a new value for the category' ); > >-$agent->base_like(qr|$expected_base|, "check base"); >+$agent->base_like(qr/$expected_base/xsm, 'check base'); > $add_form_link_exists = 0; > $delete_form_link_exists = 0; > for my $link ( $agent->links() ) { >- if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) { >+ if ( $link->url =~ m/authorised_values.pl\x3Fop=add_form&category=$category/xsm ) { > $add_form_link_exists = 1; >- }elsif( $link->url =~ m|authorised_values.pl\?op=delete&searchfield=$category| ) { >+ }elsif( $link->url =~ m/authorised_values.pl\x3Fop=delete&searchfield=$category/xsm ) { > $delete_form_link_exists = 1; > } > } > is( $add_form_link_exists, 1, 'Add a new category button should be displayed'); >-is( $delete_form_link_exists, 1, ''); >+is( $delete_form_link_exists, 1, q{}); > > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' ); > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=å¦åä¼Î¼Î¼&offset=0", 'Search the values inserted' ); > my $text = $agent->text() ; > #Tests on UTF-8 >-ok ( ( length(Encode::encode('UTF-8', $text)) != length($text) ) , 'UTF-8 are multi-byte. Good') ; >-ok ($text =~ m/å¦åä¼Î¼Î¼/, 'UTF-8 (Asia) chars are correctly present. Good'); >-ok ($text =~ m/εÏιμεq/, 'UTF-8 (Greek) chars are correctly present. Good'); >+ok ( ( length Encode::encode('UTF-8', $text) != length $text ) , 'UTF-8 are multi-byte. Good') ; >+ok ($text =~ m/å¦åä¼Î¼Î¼/xsm, 'UTF-8 (Asia) chars are correctly present. Good'); >+ok ($text =~ m/εÏιμεq/xsm, 'UTF-8 (Greek) chars are correctly present. Good'); > my @links = $agent->links; >-my $id_to_del =''; >+my $id_to_del =q{}; > foreach my $dato (@links){ > my $link = $dato->url; >- if ($link =~ m/op=delete\&searchfield=å¦åä¼Î¼Î¼\&id=(\d+)/){ >+ if ($link =~ m/op=delete\&searchfield=å¦åä¼Î¼Î¼\&id=(\d+)/xsm){ > $id_to_del = $1; > last; > } >@@ -129,7 +139,7 @@ foreach my $dato (@links){ > if ($id_to_del) { > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete&searchfield=å¦åä¼Î¼Î¼&id=$id_to_del", 'UTF_8 auth. value deleted' ); > }else{ >- ok($id_to_del ne undef, "error, link to delete not working"); >+ ok($id_to_del ne undef, 'error, link to delete not working'); > } > > #---------------------------------------- Test with only latin utf-8 (could be taken as Latin-1/ISO 8859-1) >@@ -142,42 +152,42 @@ $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' ); > $agent->form_name('Aform'); > $agent->field('category', $category); >-$agent->click_ok( '', "Create new AV category" ); >+$agent->click_ok( q{}, 'Create new AV category' ); > > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form&category=$category", 'Open to create a new AV for this category' ); > $agent->form_name('Aform'); > $agent->field('authorised_value', 'rà men'); > $agent->field('lib_opac', 'autdesc2'); > $agent->field('lib', 'desc1'); >-$agent->field('branches', ''); >-$agent->click_ok( '', "Create a new value for the category" ); >+$agent->field('branches', q{}); >+$agent->click_ok( q{}, 'Create a new value for the category' ); > > $expected_base = q|authorised_values.pl|; >-$agent->base_like(qr|$expected_base|, "check base"); >+$agent->base_like(qr/$expected_base/xsm, 'check base'); > $add_form_link_exists = 0; > $delete_form_link_exists = 0; > for my $link ( $agent->links() ) { >- if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) { >+ if ( $link->url =~ m/authorised_values.pl\x3Fop=add_form&category=$category/xsm ) { > $add_form_link_exists = 1; >- }elsif( $link->url =~ m|authorised_values.pl\?op=delete&searchfield=$category| ) { >+ }elsif( $link->url =~ m/authorised_values.pl\x3Fop=delete&searchfield=$category/xsm ) { > $delete_form_link_exists = 1; > } > } >-is( $add_form_link_exists, 1, ); >-is( $delete_form_link_exists, 1, ); >+is( $add_form_link_exists, 1, 'Add form link exists'); >+is( $delete_form_link_exists, 1, 'Delete form link exists'); > > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' ); > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=tòmas&offset=0", 'Search the values inserted' ); > my $text2 = $agent->text() ; > #Tests on UTF-8 >-ok ( ( length(Encode::encode('UTF-8', $text)) != length($text) ) , 'UTF-8 are multi-byte. Good') ; >-ok ($text2 =~ m/tòmas/, 'UTF-8 not Latin-1 first test is OK. Good'); >-ok ($text2=~ m/rà men/, 'UTF-8 not Latin-1 second test is OK. Good'); >+ok ( ( length Encode::encode('UTF-8', $text) != length $text ) , 'UTF-8 are multi-byte. Good') ; >+ok ($text2 =~ m/tòmas/xsm, 'UTF-8 not Latin-1 first test is OK. Good'); >+ok ($text2=~ m/rà men/xsm, 'UTF-8 not Latin-1 second test is OK. Good'); > my @links2 = $agent->links; >-my $id_to_del2 =''; >+my $id_to_del2 =q{}; > foreach my $dato (@links2){ > my $link = $dato->url; >- if ($link =~ m/op=delete\&searchfield=tòmas\&id=(\d+)/){ >+ if ($link =~ m/op=delete\&searchfield=tòmas\&id=(\d+)/xsm){ > $id_to_del2 = $1; > last; > } >@@ -185,7 +195,7 @@ foreach my $dato (@links2){ > if ($id_to_del2) { > $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete&searchfield=tòmas&id=$id_to_del2", 'UTF_8 auth. value deleted' ); > }else{ >- ok($id_to_del2 ne undef, "error, link to delete not working"); >+ ok($id_to_del2 ne undef, 'error, link to delete not working'); > } > > 1; >-- >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 17934
:
59173
|
59753