Bug 41918: (QA follow-up) Update prep_report tests for new SQL comment

The first patch in this series changed the SQL comment appended by
Koha::Report::prep_report from

    /* saved_sql.id: <id> */

to

    /* { saved_sql.id: <id> } { user_id: <user_id> } */

but did not update the existing assertions in t/db_dependent/Koha/Reports.t,
leaving three subtest failures in the prep_report subtest. Refresh the
expected strings to match the new format and pick up the userenv-derived
user_id (or 0 when no userenv is in scope, matching prep_report's fallback).

Test plan:
1) Apply this follow-up.
2) prove t/db_dependent/Koha/Reports.t
3) Verify all 10 tests pass (previously 3 subtests of prep_report failed).

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-04-27 17:41:11 +01:00 committed by Lucas Gass
parent 1162d2d67c
commit 521ddaacad
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 6 additions and 3 deletions

View File

@ -68,9 +68,12 @@ subtest 'prep_report' => sub {
)->store;
my $id = $report->id;
my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : 0;
my ( $sql, undef ) = $report->prep_report( ['Test|list'], ["1\n12\n\r243"] );
is(
$sql, qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') /* saved_sql.id: $id */},
$sql,
qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') /* { saved_sql.id: $id } { user_id: $user_id } */},
'Expected sql generated correctly with single param and name'
);
@ -79,14 +82,14 @@ subtest 'prep_report' => sub {
( $sql, undef ) = $report->prep_report( [ 'Test|list', 'Another' ], [ "1\n12\n\r243", 'the other' ] );
is(
$sql,
qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* saved_sql.id: $id */},
qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* { saved_sql.id: $id } { user_id: $user_id } */},
'Expected sql generated correctly with multiple params and names'
);
( $sql, undef ) = $report->prep_report( [], [ "1\n12\n\r243", 'the other' ] );
is(
$sql,
qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* saved_sql.id: $id */},
qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* { saved_sql.id: $id } { user_id: $user_id } */},
'Expected sql generated correctly with multiple params and no names'
);