Bugzilla – Attachment 86384 Details for
Bug 20478
Advance notices: send separate digest messages per library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20478: (QA follow-up) Make test more standard
Bug-20478-QA-follow-up-Make-test-more-standard.patch (text/plain), 5.22 KB, created by
Martin Renvoize
on 2019-03-08 13:01:35 UTC
(
hide
)
Description:
Bug 20478: (QA follow-up) Make test more standard
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2019-03-08 13:01:35 UTC
Size:
5.22 KB
patch
obsolete
>From 61a22dcbe1b2a03aa2f5edf53b47635aee25a12b Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 8 Mar 2019 10:35:49 +0000 >Subject: [PATCH] Bug 20478: (QA follow-up) Make test more standard > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../cronjobs/advance_notices_digest.t | 114 ++++++++++-------- > 1 file changed, 61 insertions(+), 53 deletions(-) > >diff --git a/t/db_dependent/cronjobs/advance_notices_digest.t b/t/db_dependent/cronjobs/advance_notices_digest.t >index 54b3758b23..23db520e4e 100644 >--- a/t/db_dependent/cronjobs/advance_notices_digest.t >+++ b/t/db_dependent/cronjobs/advance_notices_digest.t >@@ -19,15 +19,17 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 2; > use t::lib::TestBuilder; >-use DateTime; >+use t::lib::Mocks; > use File::Spec; > use File::Basename; >-use Data::Dumper; >+ >+use Koha::DateUtils; > > my $scriptDir = dirname(File::Spec->rel2abs( __FILE__ )); > >+my $schema = Koha::Database->new->schema; > my $dbh = C4::Context->dbh; > > my $library1; >@@ -36,11 +38,11 @@ my $library3; > my $borrower; > > sub build_test_objects { >- $dbh->{AutoCommit} = 0; >+ > $dbh->{RaiseError} = 1; > > # Set only to avoid exception. >- $ENV{"OVERRIDE_SYSPREF_dateformat"} = 'metric'; >+ t::lib::Mocks::mock_preference('dateformat', 'metric'); > > my $builder = t::lib::TestBuilder->new; > >@@ -126,7 +128,7 @@ DELETESQL > my $item3 = $builder->build({ > source => 'Item' > }); >- my $now = DateTime->now(); >+ my $now = dt_from_string(); > my $tomorrow = $now->add(days => 1)->strftime('%F'); > > my $issue1 = $builder->build({ >@@ -191,72 +193,78 @@ close $scriptfh; > > my $sthmq = $dbh->prepare('SELECT * FROM message_queue WHERE borrowernumber = ?'); > >-# >-# Test default behavior >-# >+subtest 'Default behaviour tests' => sub { > >-build_test_objects(); >+ plan tests => 3; > >-run_script($scriptContent, 'advanced_notices.pl', '-c'); >+ $schema->storage->txn_begin; > >-$sthmq->execute($borrower->{borrowernumber}); >+ build_test_objects(); > >-my $messages = $sthmq->fetchall_hashref('message_id'); >+ run_script($scriptContent, 'advanced_notices.pl', '-c'); > >-is(scalar(keys %$messages), 1, 'There is one message in the queue'); >+ $sthmq->execute($borrower->{borrowernumber}); > >-for my $message (keys %$messages) { >- $messages->{$message}->{content} =~ /(\d+) (.*)/; >- my $count = $1; >- my $branchname = $2; >+ my $messages = $sthmq->fetchall_hashref('message_id'); > >- is ($count, '3', 'Issue count is 3'); >- is ($branchname, $library1->{branchname}, 'Branchname is that of borrowers home branch.'); >-} >+ is(scalar(keys %$messages), 1, 'There is one message in the queue'); > >-$dbh->rollback; >+ for my $message (keys %$messages) { >+ $messages->{$message}->{content} =~ /(\d+) (.*)/; >+ my $count = $1; >+ my $branchname = $2; > >-# >-# Test -digest-per-branch >-# >+ is ($count, '3', 'Issue count is 3'); >+ is ($branchname, $library1->{branchname}, 'Branchname is that of borrowers home branch.'); >+ } > >-build_test_objects(); >+ $schema->storage->txn_rollback; >+}; > >-run_script($scriptContent, 'advanced_notices.pl', '-c', '-digest-per-branch'); >+subtest '--digest-per-branch tests' => sub { > >-$sthmq->execute($borrower->{borrowernumber}); >+ plan tests => 5; > >-$messages = $sthmq->fetchall_hashref('message_id'); >+ $schema->storage->txn_begin; > >-is(scalar(keys %$messages), 2, 'There are two messages in the queue'); >+ build_test_objects(); > >-my %expected = ( >- $library2->{branchname} => { >- count => 1, >- }, >- $library3->{branchname} => { >- count => 2, >- } >- ); >+ run_script($scriptContent, 'advanced_notices.pl', '-c', '-digest-per-branch'); >+ >+ $sthmq->execute($borrower->{borrowernumber}); > >-my %expected_branchnames = ( >- $library2->{branchname} => 1, >- $library3->{branchname} => 1 >-); >+ my $messages = $sthmq->fetchall_hashref('message_id'); > >-my $i = 0; >-for my $message (keys %$messages) { >- $messages->{$message}->{content} =~ /(\d+) (.*)/; >- my $count = $1; >- my $branchname = $2; >+ is(scalar(keys %$messages), 2, 'There are two messages in the queue'); > >- ok ($expected_branchnames{$branchname}, 'Branchname is that of expected issuing branch.'); >+ my %expected = ( >+ $library2->{branchname} => { >+ count => 1, >+ }, >+ $library3->{branchname} => { >+ count => 2, >+ } >+ ); > >- $expected_branchnames{$branchname} = 0; >+ my %expected_branchnames = ( >+ $library2->{branchname} => 1, >+ $library3->{branchname} => 1 >+ ); > >- is ($count, $expected{$branchname}->{count}, 'Issue count is ' . $expected{$branchname}->{count}); >+ my $i = 0; >+ for my $message (keys %$messages) { >+ $messages->{$message}->{content} =~ /(\d+) (.*)/; >+ my $count = $1; >+ my $branchname = $2; > >- $i++; >-} >+ ok ($expected_branchnames{$branchname}, 'Branchname is that of expected issuing branch.'); >+ >+ $expected_branchnames{$branchname} = 0; >+ >+ is ($count, $expected{$branchname}->{count}, 'Issue count is ' . $expected{$branchname}->{count}); >+ >+ $i++; >+ } > >-$dbh->rollback; >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 20478
:
73308
|
73309
|
73310
|
73722
|
73723
|
73724
|
80867
|
80901
|
80902
|
80903
|
86381
|
86382
|
86383
| 86384