-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Remove side effects from data provider #7478
base: develop
Are you sure you want to change the base?
Changes from all commits
05e24d3
6784617
292da87
031772e
30a6faf
08d152f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ public function run() { | |
created_at DATETIME NOT NULL, | ||
updated_at DATETIME NOT NULL, | ||
PRIMARY KEY (id) | ||
) $charset"; | ||
) $charset ENGINE=InnoDB;"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of adding this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On my machine where the default engine is MyISAM, many of the tests crash because of their interactions. Indeed, the teardown cleanup function of legacy tests uses SQL transactions with But MyISAM does not manage transactions... This is why I suggest explicit use of the InnoDB engine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pulsovi thanks for the clarification |
||
|
||
try { | ||
DB::delta( $sql ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -766,7 +766,7 @@ function test_give_email_tag_metadata() { | |
Give()->donor_meta->update_meta( $donor_id, '_give_stripe_customer_id', 2 ); | ||
|
||
$this->assertEquals( 2, __give_render_metadata_email_tag( '{meta_donor__give_stripe_customer_id}', $donor_tag_args ) ); | ||
$this->assertEquals( 1, __give_render_metadata_email_tag( '{meta_donor_id}', $donor_tag_args ) ); | ||
$this->assertEquals( $donor_id, __give_render_metadata_email_tag( '{meta_donor_id}', $donor_tag_args ) ); | ||
$this->assertEquals( 1, __give_render_metadata_email_tag( '{meta_donor_user_id}', $donor_tag_args ) ); | ||
$this->assertEquals( 'Admin User', __give_render_metadata_email_tag( '{meta_donor_name}', $donor_tag_args ) ); | ||
$this->assertEquals( '[email protected]', __give_render_metadata_email_tag( '{meta_donor_email}', $donor_tag_args ) ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these classes are extensions of
Give_DB_Meta
.However, this class, during its instantiation, will override all post modification methods via hooks such as:
This will trigger a bugged behavior if one of these classes is instantiated more than once.
In the specific case of deletion, the return value indicates the number of rows deleted from the database.
But if the hook is called by several instances of the class, this is what will happen:
0
0
, the return value is wrong.For this reason, I made the minimum possible modifications to approach singleton pattern behavior.
This is the code you present here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 interesting!
I think the singleton pattern here does make sense 👍
We'll just have to run it through QA internally to make sure everything works as expected.