Bugzilla – Attachment 142151 Details for
Bug 31870
Cleaning up t/db_dependent/Context.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31870: Context.t: Reorganize subtests
Bug-31870-Contextt-Reorganize-subtests.patch (text/plain), 3.91 KB, created by
Marcel de Rooy
on 2022-10-19 12:19:25 UTC
(
hide
)
Description:
Bug 31870: Context.t: Reorganize subtests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-10-19 12:19:25 UTC
Size:
3.91 KB
patch
obsolete
>From b95350f11a6847ebe61222f781c705beb5600883 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 19 Oct 2022 12:00:37 +0000 >Subject: [PATCH] Bug 31870: Context.t: Reorganize subtests >Content-Type: text/plain; charset=utf-8 > >Move a few tests into separate subtests. >Replace the BEGIN block. > >Test plan: >Run test again. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Context.t | 72 ++++++++++++++++++++++------------------ > 1 file changed, 39 insertions(+), 33 deletions(-) > >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index 858df48075..ff35b9e3f3 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -7,22 +7,23 @@ use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; > >+use C4::Context; > use Koha::Database; > >-BEGIN { >- my $ret; >+our $schema; >+$schema = Koha::Database->new->schema; >+ >+subtest 'Environment' => sub { >+ plan tests => 2; > # First we need to check your environmental variables >+ my $ret; > for (qw(KOHA_CONF PERL5LIB)) { > ok( $ret = $ENV{$_}, "ENV{$_} = $ret" ); > } >- use_ok('C4::Context'); >-} >- >-our $schema; >-$schema = Koha::Database->new->schema; >+}; > >-subtest 'Original tests' => sub { >- plan tests => 33; >+subtest 'Tests with preferences' => sub { >+ plan tests => 22; > $schema->storage->txn_begin; > > my $dbh; >@@ -54,25 +55,7 @@ subtest 'Original tests' => sub { > C4::Context->clear_syspref_cache(); > C4::Context->enable_syspref_cache(); > >- my $koha; >- ok($koha = C4::Context->new, 'C4::Context->new'); >- my @keys = keys %$koha; >- my $width = 0; >- ok( @keys, 'Expecting entries in context hash' ); >- if( @keys ) { >- $width = (sort {$a <=> $b} map {length} @keys)[-1]; >- } >- foreach (sort @keys) { >- ok(exists $koha->{$_}, >- '$koha->{' . sprintf('%' . $width . 's', $_) . '} exists ' >- . ((defined $koha->{$_}) ? "and is defined." : "but is not defined.") >- ); >- } >- my $config; >- ok($config = $koha->{config}, 'Getting $koha->{config} '); >- > # Testing syspref caching >- > $schema->storage->debug(1); > my $trace_read; > open my $trace, '>', \$trace_read or die "Can't open variable: $!"; >@@ -116,12 +99,6 @@ subtest 'Original tests' => sub { > is(C4::Context->preference("SillyPreference"), 'thing4', "Retrieved syspref (value='thing4') successfully from cache"); > is( $trace_read, q{}, 'Did not retrieve syspref from database'); > $trace_read = q{}; >- >- my $oConnection = C4::Context->Zconn('biblioserver', 0); >- isnt($oConnection->option('async'), 1, "ZOOM connection is synchronous"); >- $oConnection = C4::Context->Zconn('biblioserver', 1); >- is($oConnection->option('async'), 1, "ZOOM connection is asynchronous"); >- > $silly_preference->delete(); > > # AutoEmailNewUser should be a YesNo pref >@@ -131,3 +108,32 @@ subtest 'Original tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'Check context hash keys' => sub { >+ my $koha; >+ ok($koha = C4::Context->new, 'C4::Context->new'); >+ my @keys = keys %$koha; >+ my $width = 0; >+ ok( @keys, 'Expecting entries in context hash' ); >+ if( @keys ) { >+ $width = (sort {$a <=> $b} map {length} @keys)[-1]; >+ } >+ foreach (sort @keys) { >+ ok(exists $koha->{$_}, >+ '$koha->{' . sprintf('%' . $width . 's', $_) . '} exists ' >+ . ((defined $koha->{$_}) ? "and is defined." : "but is not defined.") >+ ); >+ } >+ my $config; >+ ok($config = $koha->{config}, 'Getting $koha->{config} '); >+ done_testing(); >+}; >+ >+subtest 'Zconn' => sub { >+ plan tests => 2; >+ my $oConnection = C4::Context->Zconn('biblioserver', 0); >+ isnt($oConnection->option('async'), 1, "ZOOM connection is synchronous"); >+ $oConnection = C4::Context->Zconn('biblioserver', 1); >+ is($oConnection->option('async'), 1, "ZOOM connection is asynchronous"); >+ >+}; >-- >2.30.2
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 31870
:
142149
|
142150
|
142151
|
142152
|
142453
|
142454
|
142455
|
142456