Skip to content

Commit bc6f924

Browse files
committed
Add test assertions for register_hooks.
1 parent 8e5416b commit bc6f924

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/phpunit/includes/Core/Conversion_Tracking/Conversion_Event_Providers/FakeConversionEventProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@ public function register_script() {
5050
return $script_asset;
5151
}
5252

53+
/**
54+
* Registers any actions/hooks for this provider.
55+
*
56+
* @since 1.129.0
57+
*/
58+
public function register_hooks() {
59+
// Register a fake action.
60+
add_action( 'fake_provider_action', '__return_true' );
61+
}
62+
5363
}

tests/phpunit/integration/Core/Conversion_Tracking/Conversion_TrackingTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ public function test_register__not_enqueued_when_tracking_disabled() {
8282
* @dataProvider data_modules
8383
*/
8484
public function test_register__enqueued_when_snippet_inserted( $module_slug ) {
85+
$this->assertFalse( has_action( 'fake_provider_action' ) );
86+
8587
$this->conversion_tracking->register();
8688

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

9092
$this->assertTrue( wp_script_is( 'gsk-cep-' . FakeConversionEventProvider_Active::CONVERSION_EVENT_PROVIDER_SLUG ) );
9193
$this->assertFalse( wp_script_is( 'gsk-cep-' . FakeConversionEventProvider::CONVERSION_EVENT_PROVIDER_SLUG ) );
94+
95+
$this->assertTrue( has_action( 'fake_provider_action' ) );
9296
}
9397

9498
public function data_modules() {

0 commit comments

Comments
 (0)