From 83c2933d50b4736bbaddcf589769ed84a4a0c8d0 Mon Sep 17 00:00:00 2001 From: Doeke Norg Date: Thu, 11 Apr 2024 12:29:29 +0200 Subject: [PATCH] fix tests --- includes/widgets/search-widget/class-search-widget.php | 2 +- .../templates/search-field-number_range.php | 10 ++++++++-- tests/GV_RESTUnitTestCase.php | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/widgets/search-widget/class-search-widget.php b/includes/widgets/search-widget/class-search-widget.php index c9d3ec6a2..640a55543 100644 --- a/includes/widgets/search-widget/class-search-widget.php +++ b/includes/widgets/search-widget/class-search-widget.php @@ -1245,7 +1245,7 @@ public function gf_query_filter( &$query, $view, $request ) { private function is_product_field( array $filter ): bool { $field = GFAPI::get_field( $filter['form_id'] ?? 0, $filter['key'] ?? 0 ); - return \GFCommon::is_product_field( $field->type ); + return $field && \GFCommon::is_product_field( $field->type ); } /** diff --git a/includes/widgets/search-widget/templates/search-field-number_range.php b/includes/widgets/search-widget/templates/search-field-number_range.php index 31acfc8af..e7f1bed46 100644 --- a/includes/widgets/search-widget/templates/search-field-number_range.php +++ b/includes/widgets/search-widget/templates/search-field-number_range.php @@ -26,10 +26,16 @@ $is_currency = 'currency' === $field->numberFormat; } -// Add decimal support for total price. +/** + * Modify the step value for the input fields. + * + * @since $ver$ + * @param string $value The step size. + * @param GravityView_View $gravityview_view The view object. + */ $step = apply_filters( 'gk/gravityview/search/number_range/step', - 'quantity' === $gravityview_view->search_field['type'] ? '1' : '0.01', + 'quantity' === $gravityview_view->search_field['type'] ? '0' : '0.01', $gravityview_view ); ?> diff --git a/tests/GV_RESTUnitTestCase.php b/tests/GV_RESTUnitTestCase.php index 58be96b8a..b12a793aa 100644 --- a/tests/GV_RESTUnitTestCase.php +++ b/tests/GV_RESTUnitTestCase.php @@ -31,6 +31,12 @@ function setUp() : void { if ( version_compare( GFForms::$version, '2.2', '<' ) ) { @GFForms::setup_database(); } + + /** + * Add extra level of output buffering to avoid issues. + * @see \GV\REST\Route::ob_start() + */ + ob_start(); } /**