Skip to content

Commit

Permalink
Refactor: Remove side effects from data provider
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
David GABISON committed Sep 5, 2024
1 parent 5bbb79b commit 53407f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/includes/legacy/tests-misc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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; }],
];
}

/**
Expand Down

0 comments on commit 53407f1

Please sign in to comment.