Skip to content

Commit

Permalink
Add test assertions for register_hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuasha420 committed Jun 14, 2024
1 parent 8e5416b commit bc6f924
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ public function register_script() {
return $script_asset;
}

/**
* Registers any actions/hooks for this provider.
*
* @since 1.129.0
*/
public function register_hooks() {
// Register a fake action.
add_action( 'fake_provider_action', '__return_true' );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ public function test_register__not_enqueued_when_tracking_disabled() {
* @dataProvider data_modules
*/
public function test_register__enqueued_when_snippet_inserted( $module_slug ) {
$this->assertFalse( has_action( 'fake_provider_action' ) );

$this->conversion_tracking->register();

do_action( "googlesitekit_{$module_slug}_init_tag" );
do_action( 'wp_enqueue_scripts' );

$this->assertTrue( wp_script_is( 'gsk-cep-' . FakeConversionEventProvider_Active::CONVERSION_EVENT_PROVIDER_SLUG ) );
$this->assertFalse( wp_script_is( 'gsk-cep-' . FakeConversionEventProvider::CONVERSION_EVENT_PROVIDER_SLUG ) );

$this->assertTrue( has_action( 'fake_provider_action' ) );
}

public function data_modules() {
Expand Down

0 comments on commit bc6f924

Please sign in to comment.