Bugzilla – Attachment 75091 Details for
Bug 19821
Run tests on a separate database
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19821: Do not modify KOHA_CONF, use new database_test entry instead
Bug-19821-Do-not-modify-KOHACONF-use-new-databaset.patch (text/plain), 3.47 KB, created by
Jonathan Druart
on 2018-05-04 17:54:38 UTC
(
hide
)
Description:
Bug 19821: Do not modify KOHA_CONF, use new database_test entry instead
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-05-04 17:54:38 UTC
Size:
3.47 KB
patch
obsolete
>From 7ef8c52be4c4ee52316303d3ec92e9b721fcb7db Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 4 May 2018 14:41:14 -0300 >Subject: [PATCH] Bug 19821: Do not modify KOHA_CONF, use new database_test > entry instead > >I have tried to use the original idea of this patch for bug 19185, but >it cannot work as it. ENV is not shared between processus and KOHA_CONF >will not be read by webserver (used for selenium tests). > >Moreover on bug 19185 we are testing the installation process and we do >not want the database to be populated with sample data, we just need a >new and clean DB. >--- > t/lib/Bootstrap.pm | 56 +++++++++--------------------------------------------- > 1 file changed, 9 insertions(+), 47 deletions(-) > >diff --git a/t/lib/Bootstrap.pm b/t/lib/Bootstrap.pm >index 1b70030536..fbba437591 100644 >--- a/t/lib/Bootstrap.pm >+++ b/t/lib/Bootstrap.pm >@@ -6,48 +6,19 @@ use DBI; > use File::Temp qw( tempfile ); > use XML::LibXML; > >+our $database; > sub import { > my ($self, %args) = @_; > >- unless (defined $args{database}) { >- die "Test database is not defined"; >- } >- >- $args{marcflavour} //= 'MARC21'; >- >- my $xml = XML::LibXML->load_xml(location => $ENV{KOHA_CONF}); >- my $root = $xml->documentElement(); >- my ($databaseElement) = $root->findnodes('//config/database'); >- my $currentDatabase = $databaseElement->textContent(); >- >- if ($currentDatabase eq $args{database}) { >- die "Test database is the same as database in KOHA_CONF, abort!"; >- } >- >- $databaseElement->firstChild()->setData($args{database}); >- >- my ($fh, $filename) = tempfile('koha-conf.XXXXXX', TMPDIR => 1, UNLINK => 1); >- $xml->toFH($fh); >- close $fh; >- >- $ENV{KOHA_CONF} = $filename; >- > require C4::Context; > C4::Context->import; > >- require C4::Installer; >- C4::Installer->import; >- >- require C4::Languages; >- > my $host = C4::Context->config('hostname'); > my $port = C4::Context->config('port'); >- my $database = C4::Context->config('database'); >+ $database = C4::Context->config("database_test") || C4::Context->config('database'); > my $user = C4::Context->config('user'); > my $pass = C4::Context->config('pass'); > >- say "Create test database $database..."; >- > my $dbh = DBI->connect("dbi:mysql:;host=$host;port=$port", $user, $pass, { > RaiseError => 1, > PrintError => 0, >@@ -56,22 +27,13 @@ sub import { > $dbh->do("DROP DATABASE IF EXISTS $database"); > $dbh->do("CREATE DATABASE $database"); > >- my $installer = C4::Installer->new(); >- $installer->load_db_schema(); >- $installer->set_marcflavour_syspref($args{marcflavour}); >- my (undef, $fwklist) = $installer->marc_framework_sql_list('en', $args{marcflavour}); >- my (undef, $list) = $installer->sample_data_sql_list('en'); >- my @frameworks; >- foreach my $fwk (@$fwklist, @$list) { >- foreach my $framework (@{ $fwk->{frameworks} }) { >- push @frameworks, $framework->{fwkfile}; >- } >- } >- my $all_languages = C4::Languages::getAllLanguages(); >- $installer->load_sql_in_order($all_languages, @frameworks); >- require Koha::SearchEngine::Elasticsearch; >- Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; >- $installer->set_version_syspref(); > } > >+END { >+ my $dbh = C4::Context->dbh; >+ $dbh->do("DROP DATABASE IF EXISTS $database") if $database; >+ Koha::Caches->get_instance()->flush_all; >+ Koha::Caches->get_instance('config')->flush_all; >+}; >+ > 1; >-- >2.11.0
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 19821
:
69825
|
69842
|
69843
|
69844
|
71817
|
75045
|
75091
|
75092
|
81893
|
81894
|
81895
|
81896
|
81897
|
81898
|
81899
|
81900
|
99435
|
99436
|
99437
|
99438
|
99439
|
99440
|
99441
|
103409
|
103410
|
103411
|
103412
|
103413
|
103414
|
103415
|
105876
|
105877
|
105878
|
105879
|
105880
|
105881
|
105882
|
120417
|
120418
|
120419
|
120420
|
120421
|
120422
|
120423