From 0bfcac5a079318be7c5d20c6d52af45169eab922 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 4 Sep 2018 12:46:30 +0000 Subject: [PATCH] Bug 18316: (follow-up) Fix tests and update statement Signed-off-by: Ere Maijala Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- .../mysql/atomicupdate/bug_18316_add-weight-column.perl | 2 +- .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 7 +++---- t/db_dependent/Koha/SearchField.t | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl b/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl index a076d8b402..7e6710e719 100644 --- a/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl +++ b/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl @@ -1,7 +1,7 @@ $DBversion = 'XXX'; if( CheckVersion( $DBversion ) ) { if( !column_exists( 'search_field', 'weight' ) ) { - $dbh->do( "ALTER TABLE `search_field` ADD COLUMN `weight` decimal(5,2) DEFAULT NULL" ); + $dbh->do( "ALTER TABLE `search_field` ADD COLUMN `weight` decimal(5,2) DEFAULT NULL AFTER `type`" ); } SetVersion( $DBversion ); diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t index a526604552..5c1f7f20ba 100644 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -17,9 +17,9 @@ use Modern::Perl; -use Test::More tests => 2; use C4::Context; use Test::Exception; +use t::lib::TestBuilder; use Test::More tests => 3; use Koha::Database; @@ -160,11 +160,10 @@ subtest 'build_query with weighted fields tests' => sub { undef, undef, undef, { weighted_fields => 1 }); my $fields = $query->{query}{query_string}{fields}; - is(scalar(@$fields), 3, 'Search is done on 3 fields'); is($fields->[0], '_all', 'First search field is _all'); - is($fields->[1], 'title^25', 'Second search field is title'); - is($fields->[2], 'subject^15', 'Third search field is subject'); + is($fields->[1], 'title^25.00', 'Second search field is title'); + is($fields->[2], 'subject^15.00', 'Third search field is subject'); }; $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/SearchField.t b/t/db_dependent/Koha/SearchField.t index 737d78b112..af8f35d4cb 100644 --- a/t/db_dependent/Koha/SearchField.t +++ b/t/db_dependent/Koha/SearchField.t @@ -193,10 +193,10 @@ my @w_fields = Koha::SearchFields->weighted_fields(); is(scalar(@w_fields), 3, 'weighted_fields should return 3 weighted fields.'); is($w_fields[0]->name, 'title', 'First field is title.'); -is($w_fields[0]->weight, 25, 'Title weight is 25.'); +is($w_fields[0]->weight+0, 25, 'Title weight is 25.'); is($w_fields[1]->name, 'subject', 'Second field is subject.'); -is($w_fields[1]->weight, 15, 'Subject weight is 15.'); +is($w_fields[1]->weight+0, 15, 'Subject weight is 15.'); is($w_fields[2]->name, 'author', 'Third field is author.'); -is($w_fields[2]->weight, 5, 'Author weight is 5.'); +is($w_fields[2]->weight+0, 5, 'Author weight is 5.'); -$schema->storage->txn_rollback; \ No newline at end of file +$schema->storage->txn_rollback;