Bug 24879: (follow-up) Fix test suite

Running cataloguing pluings (in cataloguing/value_builder) now requires
authentification.

This patch adds in failing unit tests a mock of C4::Auth::check_cookie_auth

Test with:
prove t/db_dependent/FrameworkPlugin.t t/db_dependent/Koha/UI/Form/Builder/Biblio.t t/db_dependent/Koha/UI/Form/Builder/Item.t t/db_dependent/Serials.t

(cherry picked from commit f8a23b8ef4)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

suite
This commit is contained in:
Fridolin Somers 2024-03-27 10:20:03 +01:00 committed by Frédéric Demians
parent 452f4d5acf
commit 92030f1aba
4 changed files with 16 additions and 0 deletions

View file

@ -144,6 +144,7 @@ sub test05 {
my $mOutput = Test::MockModule->new('C4::Output'); my $mOutput = Test::MockModule->new('C4::Output');
$mContext->mock( 'userenv', \&mock_userenv ); $mContext->mock( 'userenv', \&mock_userenv );
$mAuth->mock( 'checkauth', sub { return ( 1, undef, 1, all_perms() ); } ); $mAuth->mock( 'checkauth', sub { return ( 1, undef, 1, all_perms() ); } );
$mAuth->mock( 'check_cookie_auth', sub { return ('ok') } );
$mOutput->mock('output_html_with_http_headers', sub { ++$launched; } ); $mOutput->mock('output_html_with_http_headers', sub { ++$launched; } );
my $cgi=CGI->new; my $cgi=CGI->new;

View file

@ -18,6 +18,7 @@
use Modern::Perl; use Modern::Perl;
use Test::More tests => 7; use Test::More tests => 7;
use Test::MockModule;
use C4::ClassSource; use C4::ClassSource;
@ -26,6 +27,10 @@ use Koha::DateUtils qw( dt_from_string );
use Koha::ItemTypes; use Koha::ItemTypes;
use Koha::Libraries; use Koha::Libraries;
# Auth required for cataloguing plugins
my $mAuth = Test::MockModule->new('C4::Auth');
$mAuth->mock( 'check_cookie_auth', sub { return ('ok') } );
my $schema = Koha::Database->new->schema; my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin; $schema->storage->txn_begin;

View file

@ -17,6 +17,7 @@
use Modern::Perl; use Modern::Perl;
use Test::More tests => 9; use Test::More tests => 9;
use Test::MockModule;
use Data::Dumper qw( Dumper ); use Data::Dumper qw( Dumper );
use utf8; use utf8;
@ -28,6 +29,10 @@ use Koha::UI::Form::Builder::Item;
use t::lib::TestBuilder; use t::lib::TestBuilder;
use t::lib::Mocks; use t::lib::Mocks;
# Auth required for cataloguing plugins
my $mAuth = Test::MockModule->new('C4::Auth');
$mAuth->mock( 'check_cookie_auth', sub { return ('ok') } );
my $schema = Koha::Database->new->schema; my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin; $schema->storage->txn_begin;

View file

@ -16,12 +16,17 @@ use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Acquisition::Booksellers; use Koha::Acquisition::Booksellers;
use t::lib::Mocks; use t::lib::Mocks;
use t::lib::TestBuilder; use t::lib::TestBuilder;
use Test::MockModule;
use Test::More tests => 52; use Test::More tests => 52;
BEGIN { BEGIN {
use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate )); use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
} }
# Auth required for cataloguing plugins
my $mAuth = Test::MockModule->new('C4::Auth');
$mAuth->mock( 'check_cookie_auth', sub { return ('ok') } );
my $schema = Koha::Database->new->schema; my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin; $schema->storage->txn_begin;
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;