Skip to content

Commit a4d836b

Browse files
committed
test: use actions and filters instead of uopz
1 parent bce6161 commit a4d836b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/wpunit/Traits/Custom_Table_Query_MethodsTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,12 @@ public function should_ignore_sub_where_with_missing_column_key() {
493493
$table::insert( [ 'name' => 'Test 1', 'slug' => 'test-1', 'status' => 1 ] );
494494
$table::insert( [ 'name' => 'Test 2', 'slug' => 'test-2', 'status' => 0 ] );
495495

496+
add_filter( 'doing_it_wrong_trigger_error', '__return_false' );
497+
496498
$doing_it_wrong_called = false;
497-
uopz_set_return( '_doing_it_wrong', function() use ( &$doing_it_wrong_called ) {
499+
add_action( 'doing_it_wrong_run', function() use ( &$doing_it_wrong_called ) {
498500
$doing_it_wrong_called = true;
499-
}, true );
501+
} );
500502

501503
// Malformed: missing 'column' key.
502504
$results = $table::paginate(
@@ -510,8 +512,6 @@ public function should_ignore_sub_where_with_missing_column_key() {
510512
1
511513
);
512514

513-
uopz_unset_return( '_doing_it_wrong' );
514-
515515
$this->assertTrue( $doing_it_wrong_called, '_doing_it_wrong should be called' );
516516

517517
// Should return all rows since the malformed filter is ignored.
@@ -534,9 +534,11 @@ public function should_handle_sub_where_with_missing_value_key() {
534534

535535
$doing_it_wrong_called = false;
536536

537-
uopz_set_return( '_doing_it_wrong', function () use ( &$doing_it_wrong_called ) {
537+
add_filter( 'doing_it_wrong_trigger_error', '__return_false' );
538+
539+
add_action( 'doing_it_wrong_run', function () use ( &$doing_it_wrong_called ) {
538540
$doing_it_wrong_called = true;
539-
}, true );
541+
} );
540542

541543
// Missing 'value' key - should default to checking column is not empty.
542544
$results = $table::paginate(
@@ -549,8 +551,6 @@ public function should_handle_sub_where_with_missing_value_key() {
549551
1
550552
);
551553

552-
uopz_unset_return( '_doing_it_wrong' );
553-
554554
$this->assertFalse( $doing_it_wrong_called, '_doing_it_wrong should not be called' );
555555

556556
// Should return only the row with non-empty name.

0 commit comments

Comments
 (0)