Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions tests/phpunit/tests/abilities-api/wpAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ public function test_before_execute_ability_action() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute( 5 );

remove_action( 'wp_before_execute_ability', $callback );

$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
$this->assertSame( 5, $action_input, 'Action should receive correct input' );
$this->assertSame( 10, $result, 'Ability should execute correctly' );
Expand Down Expand Up @@ -613,8 +611,6 @@ public function test_before_execute_ability_action_no_input() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute();

remove_action( 'wp_before_execute_ability', $callback );

$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
$this->assertNull( $action_input, 'Action should receive null input when no input provided' );
$this->assertSame( 42, $result, 'Ability should execute correctly' );
Expand Down Expand Up @@ -655,8 +651,6 @@ public function test_after_execute_ability_action() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute( 7 );

remove_action( 'wp_after_execute_ability', $callback );

$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
$this->assertSame( 7, $action_input, 'Action should receive correct input' );
$this->assertSame( 21, $action_result, 'Action should receive correct result' );
Expand Down Expand Up @@ -694,8 +688,6 @@ public function test_after_execute_ability_action_no_input() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute();

remove_action( 'wp_after_execute_ability', $callback );

$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
$this->assertNull( $action_input, 'Action should receive null input when no input provided' );
$this->assertSame( 'test-result', $action_result, 'Action should receive correct result' );
Expand Down Expand Up @@ -734,9 +726,6 @@ public function test_actions_not_fired_on_permission_failure() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute();

remove_action( 'wp_before_execute_ability', $before_callback );
remove_action( 'wp_after_execute_ability', $after_callback );

$this->assertFalse( $before_action_fired, 'before_execute_ability action should not be fired on permission failure' );
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired on permission failure' );
$this->assertInstanceOf( WP_Error::class, $result, 'Should return WP_Error on permission failure' );
Expand Down Expand Up @@ -774,9 +763,6 @@ public function test_after_action_not_fired_on_execution_error() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute();

remove_action( 'wp_before_execute_ability', $before_callback );
remove_action( 'wp_after_execute_ability', $after_callback );

$this->assertTrue( $before_action_fired, 'before_execute_ability action should be fired even if execution fails' );
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired when execution returns WP_Error' );
$this->assertInstanceOf( WP_Error::class, $result, 'Should return WP_Error from execution callback' );
Expand Down Expand Up @@ -819,9 +805,6 @@ public function test_after_action_not_fired_on_output_validation_error() {
$ability = new WP_Ability( self::$test_ability_name, $args );
$result = $ability->execute();

remove_action( 'wp_before_execute_ability', $before_callback );
remove_action( 'wp_after_execute_ability', $after_callback );

$this->assertTrue( $before_action_fired, 'before_execute_ability action should be fired even if output validation fails' );
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired when output validation fails' );
$this->assertInstanceOf( WP_Error::class, $result, 'Should return WP_Error for output validation failure' );
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/abilities-api/wpRegisterAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,6 @@ public function test_get_existing_ability_using_callback() {

$result = wp_get_ability( $name );

remove_action( 'wp_abilities_api_init', $callback );

$this->assertEquals(
new WP_Ability( $name, $args ),
$result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ public function test_get_existing_category_using_callback(): void {

$result = wp_get_ability_category( $name );

remove_action( 'wp_abilities_api_categories_init', $callback );

$this->assertInstanceOf( WP_Ability_Category::class, $result );
$this->assertSame( self::$test_ability_category_name, $result->get_slug() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ public function test_get_item_with_selected_fields(): void {
$response = $this->server->dispatch( $request );
add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 );
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ public function test_get_item_with_selected_fields(): void {
$response = $this->server->dispatch( $request );
add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 );
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );

Expand All @@ -349,7 +348,6 @@ public function test_get_item_with_embed_context(): void {
$response = $this->server->dispatch( $request );
add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 );
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );

Expand Down
Loading