From 8e837fc493ce313340e59e379d0b9d245ea60ffe Mon Sep 17 00:00:00 2001 From: David GABISON Date: Mon, 5 Aug 2024 15:18:03 +0200 Subject: [PATCH] Refactor: Remove side effects from data provider - Eliminated side effects in test_give_meta_helpers data provider - Ensures consistent test environment regardless of --filter usage This change prevents unexpected failures when running specific tests with PHPUnit's --filter option. --- tests/includes/legacy/tests-misc-functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/includes/legacy/tests-misc-functions.php b/tests/includes/legacy/tests-misc-functions.php index b868dc48f5..88396f1881 100644 --- a/tests/includes/legacy/tests-misc-functions.php +++ b/tests/includes/legacy/tests-misc-functions.php @@ -102,6 +102,8 @@ public function give_get_currency_name_data_provider() { * @dataProvider give_meta_helpers_provider */ public function test_give_meta_helpers( $form_or_donation_id ) { + $form_or_donation_id = $form_or_donation_id(); + $value = give_get_meta( $form_or_donation_id, 'testing_meta', true, 'TEST1' ); $this->assertEquals( 'TEST1', $value ); @@ -129,10 +131,10 @@ public function test_give_meta_helpers( $form_or_donation_id ) { * @access private */ public function give_meta_helpers_provider() { - return array( - array( Give_Helper_Payment::create_simple_payment() ), - array( Give_Helper_Form::create_simple_form()->id ), - ); + return [ + [function () { return Give_Helper_Payment::create_simple_payment(); }], + [function () { return Give_Helper_Form::create_simple_form()->id; }], + ]; } /**