Skip to content

Commit

Permalink
Add a way to test that the arguments are extracted.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Jan 19, 2024
1 parent 7c1bf8d commit 93eeddb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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
8 changes: 7 additions & 1 deletion tests/phpunit/tests/export/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ public function test_hook_names_standardized() {
);

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

0 comments on commit 93eeddb

Please sign in to comment.