Skip to content

Commit

Permalink
Unit Test: Ensure that apply_filters is extracted, and that the param…
Browse files Browse the repository at this point in the history
…eters to it are as well. (#241)
  • Loading branch information
dd32 authored Jan 19, 2024
1 parent fcb0828 commit 7fc2227
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/phpunit/includes/export-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ protected function assertEntityContains( $entity, $type, $expected ) {
foreach ( $entity[ $type ] as $exported ) {
if ( $exported['line'] == $expected['line'] ) {
foreach ( $expected as $key => $expected_value ) {
$this->assertEquals( $expected_value, $exported[ $key ] );
if ( isset( $exported[ $key ] ) ) {
$exported_value = $exported[ $key ];
} else {
$exported_value = _wp_array_get( $exported, explode( '.', $key ), null );
}

$this->assertEquals( $expected_value, $exported_value );
}

return;
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/export/hooks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ do_action( "action_with_double_quotes" );
do_action( $variable . '-action' );
do_action( "another-{$variable}-action" );
do_action( 'hook_' . $object->property . '_pre' );
apply_filters( 'plain_filter', $variable, $filter_context );
10 changes: 10 additions & 0 deletions tests/phpunit/tests/export/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,15 @@ public function test_hook_names_standardized() {
$this->assertFileContainsHook(
array( 'name' => 'hook_{$object->property}_pre', 'line' => 7 )
);

$this->assertFileContainsHook(
array(
'type' => 'filter',
'name' => 'plain_filter',
'line' => 8,
'arguments.0' => '$variable',
'arguments.1' => '$filter_context'
)
);
}
}

0 comments on commit 7fc2227

Please sign in to comment.