From 69516294a5a0bc6d8c284670082863f3db2265bc Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 15 Feb 2018 09:08:59 +0100 Subject: [PATCH] Bug 20204: Add TestBuilder to replace CPL branch Remove CPL; without this branch, the test crashes. Rearrange modules at the start. Add Koha::Database calls. Move a few global my vars to our level. Remove intermediate rollbacks. Test plan: [1] Run prove t/db_dependent/FrameworkPlugin.t Ignore noise from unimarc plugins :) Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- t/db_dependent/FrameworkPlugin.t | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/t/db_dependent/FrameworkPlugin.t b/t/db_dependent/FrameworkPlugin.t index c85eb9fcf9..345499d7f0 100644 --- a/t/db_dependent/FrameworkPlugin.t +++ b/t/db_dependent/FrameworkPlugin.t @@ -1,46 +1,45 @@ use Modern::Perl; -use C4::Auth; -use C4::Output; -use Koha::FrameworkPlugin; - use CGI; use File::Temp qw/tempfile/; use Getopt::Long; use Test::MockModule; use Test::More tests => 5; -my @includes; +use t::lib::TestBuilder; + +use C4::Auth; +use C4::Output; +use Koha::Database; +use Koha::FrameworkPlugin; + +our @includes; GetOptions( 'include=s{,}' => \@includes ); #not used by default ! -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; +our $dbh = C4::Context->dbh; +our $builder = t::lib::TestBuilder->new; subtest 'Test01 -- Simple tests for new and name' => sub { plan tests => 7; test01(); - $dbh->rollback; }; subtest 'Test02 -- test build with old styler and marc21_leader' => sub { plan tests => 5; test02(); - $dbh->rollback; }; subtest 'Test03 -- tests with bad plugins' => sub { test03(); - $dbh->rollback; }; subtest 'Test04 -- tests with new style plugin' => sub { plan tests => 5; test04(); - $dbh->rollback; }; subtest 'Test05 -- tests with build and launch for default plugins' => sub { test05( \@includes ); - $dbh->rollback; }; -$dbh->rollback; +$schema->storage->txn_rollback; sub test01 { #empty plugin @@ -179,7 +178,8 @@ unimarc_field_4XX.pl |; } sub mock_userenv { - return { branch => 'CPL', flags => 1, id => 1 }; + my $branch = $builder->build({ source => 'Branch' }); + return { branch => $branch->{branchcode}, flags => 1, id => 1 }; } sub all_perms { -- 2.39.5