Bugzilla – Attachment 155884 Details for
Bug 34825
Move Letters.t to t/db_dependent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34825: Remove Test::DBIx::Class from Letters.t
Bug-34825-Remove-TestDBIxClass-from-Letterst.patch (text/plain), 4.12 KB, created by
Marcel de Rooy
on 2023-09-19 07:13:46 UTC
(
hide
)
Description:
Bug 34825: Remove Test::DBIx::Class from Letters.t
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-09-19 07:13:46 UTC
Size:
4.12 KB
patch
obsolete
>From eb40e15182cd2ea1150c72fe4988eb402681163c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 19 Sep 2023 06:50:52 +0000 >Subject: [PATCH] Bug 34825: Remove Test::DBIx::Class from Letters.t >Content-Type: text/plain; charset=utf-8 > >Includes a tidy. > >Test plan: >Run t/Letters.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/Letters.t | 76 +++++++++++++++++++++++++++++------------------------ > 1 file changed, 41 insertions(+), 35 deletions(-) > >diff --git a/t/Letters.t b/t/Letters.t >index ceec8d776b..4846de56a8 100755 >--- a/t/Letters.t >+++ b/t/Letters.t >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Copyright Koha development team 2007 >+# > # This file is part of Koha. > # > # Koha is free software; you can redistribute it and/or modify it >@@ -18,49 +20,53 @@ > use Modern::Perl; > > use Test::MockModule; >-use Test::More; >+use Test::More tests => 3; > >-use Module::Load::Conditional qw/check_install/; >+use t::lib::Mocks; >+use t::lib::TestBuilder; > >-BEGIN { >- if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 6; >- } else { >- plan skip_all => "Need Test::DBIx::Class" >- } >-} >+use Koha::Database; > >-use Test::DBIx::Class; >-use t::lib::Mocks; >+use_ok('C4::Letters', qw( GetLetters )); > >-fixtures_ok [ >- Letter => [ >- [ 'module', 'code', 'branchcode', 'name', 'is_html', 'title', 'content', 'lang' ], >- [ 'blah', 'ISBN', 'NBSI', 'book', 1, 'green', 'blahblah', 'french' ], >- [ 'bleh', 'ISSN', 'NSSI', 'page', 0, 'blue', 'blehbleh', 'american' ] >- ], >-], 'add fixtures'; >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+our $builder = t::lib::TestBuilder->new; > >-my $db = Test::MockModule->new('Koha::Database'); >-$db->mock( _new_schema => sub { return Schema(); } ); >+subtest 'GetLetters' => sub { >+ plan tests => 2; >+ t::lib::Mocks::mock_preference( 'dateformat', 'metric' ); > >-use_ok('C4::Letters', qw( GetLetters )); >+ my $data_1 = { >+ module => 'blah', code => 'ISBN', branchcode => 'NBSI', name => 'book', is_html => 1, title => 'green', >+ content => 'blahblah', lang => 'french' >+ }; >+ my $data_2 = { >+ module => 'blah', code => 'ISSN', branchcode => 'NSSI', name => 'page', is_html => 0, title => 'blue', >+ content => 'bleble', lang => 'american' >+ }; >+ $builder->build_object( { class => 'Koha::Notice::Templates', value => $data_1 } ); >+ $builder->build_object( { class => 'Koha::Notice::Templates', value => $data_2 } ); > >-t::lib::Mocks::mock_preference('dateformat', 'metric'); >+ my $letters = GetLetters( { module => 'blah' } ); >+ is( scalar(@$letters), 2, 'GetLetters returns the 2 inserted letters' ); > >-my $letters = C4::Letters::GetLetters(); >+ my ($ISBN_letter) = grep { $_->{code} eq 'ISBN' } @$letters; >+ is( $ISBN_letter->{name}, 'book', 'letter name for "ISBN" letter is book' ); >+}; > >-my ( $ISBN_letter ) = grep {$_->{code} eq 'ISBN'} @$letters; >-is( $ISBN_letter->{name}, 'book', 'letter name for "ISBN" letter is book' ); >-is( scalar( @$letters ), 2, 'GetLetters returns the 2 inserted letters' ); >+subtest '_parseletter' => sub { >+ plan tests => 2; > >-# Regression test for bug 10843 >-# $dt->add takes a scalar, not undef >-my $letter; >-t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', undef); >-$letter = C4::Letters::_parseletter( undef, 'reserves', {waitingdate => "2013-01-01"} ); >-is( ref($letter), 'HASH'); >-t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 1); >-$letter = C4::Letters::_parseletter( undef, 'reserves', {waitingdate => "2013-01-01"} ); >-is( ref($letter), 'HASH'); >+ # Regression test for bug 10843 >+ # $dt->add takes a scalar, not undef >+ my $letter; >+ t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', undef ); >+ $letter = C4::Letters::_parseletter( undef, 'reserves', { waitingdate => "2013-01-01" } ); >+ is( ref($letter), 'HASH' ); >+ t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', 1 ); >+ $letter = C4::Letters::_parseletter( undef, 'reserves', { waitingdate => "2013-01-01" } ); >+ is( ref($letter), 'HASH' ); >+}; > >+$schema->storage->txn_begin; >-- >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 34825
:
155884
|
155885
|
156205
|
156206