-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add site health checks for Ads module. #8379
Changes from 6 commits
9a2dfa3
654837d
09f651a
e8d1882
fe654f9
da5e317
cdd6d76
9758b20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,16 +15,18 @@ | |
use Google\Site_Kit\Core\Modules\Module_Settings; | ||
use Google\Site_Kit\Core\Modules\Module_With_Assets; | ||
use Google\Site_Kit\Core\Modules\Module_With_Assets_Trait; | ||
use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields; | ||
use Google\Site_Kit\Core\Modules\Module_With_Settings; | ||
use Google\Site_Kit\Core\Modules\Module_With_Settings_Trait; | ||
use Google\Site_Kit\Core\Modules\Module_With_Tag; | ||
use Google\Site_Kit\Core\Modules\Module_With_Tag_Trait; | ||
use Google\Site_Kit\Core\Tags\Guards\Tag_Environment_Type_Guard; | ||
use Google\Site_Kit\Core\Tags\Guards\Tag_Verify_Guard; | ||
use Google\Site_Kit\Core\Modules\Tags\Module_Tag_Matchers; | ||
use Google\Site_Kit\Modules\Ads\Settings; | ||
use Google\Site_Kit\Modules\Ads\Tag_Guard; | ||
use Google\Site_Kit\Modules\Ads\Tag_Matchers; | ||
use Google\Site_Kit\Modules\Ads\Web_Tag; | ||
use Google\Site_Kit\Core\Tags\Guards\Tag_Environment_Type_Guard; | ||
use Google\Site_Kit\Core\Tags\Guards\Tag_Verify_Guard; | ||
|
||
/** | ||
* Class representing the Ads module. | ||
|
@@ -33,8 +35,9 @@ | |
* @access private | ||
* @ignore | ||
*/ | ||
final class Ads extends Module implements Module_With_Assets, Module_With_Settings, Module_With_Tag { | ||
final class Ads extends Module implements Module_With_Assets, Module_With_Debug_Fields, Module_With_Settings, Module_With_Tag { | ||
use Module_With_Assets_Trait; | ||
use Module_With_Tag_Trait; | ||
use Module_With_Settings_Trait; | ||
use Module_With_Tag_Trait; | ||
|
||
|
@@ -159,6 +162,24 @@ public function register_tag() { | |
$tag->register(); | ||
} | ||
|
||
/** | ||
* Gets an array of debug field definitions. | ||
* | ||
* @since n.e.x.t | ||
* | ||
* @return array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a description for what is returned from this function to make it consistent with other method phpdocs. |
||
*/ | ||
public function get_debug_fields() { | ||
$settings = $this->get_settings()->get(); | ||
|
||
return array( | ||
'ads_conversion_id' => array( | ||
'label' => __( 'Ads Conversion ID', 'google-site-kit' ), | ||
'value' => $settings['adsConversionID'], | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Returns the Module_Tag_Matchers instance. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
/** | ||
* @group Modules | ||
* @group Ads | ||
*/ | ||
class AdsTest extends TestCase { | ||
|
||
|
@@ -50,6 +51,19 @@ public function test_settings_reset_on_deactivation() { | |
$this->assertFalse( $ads_settings ); | ||
} | ||
|
||
public function test_get_debug_fields() { | ||
$ads = new Ads( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); | ||
|
||
$ads->get_settings()->set( array( 'adsConversionID' => 'AW-123456789' ) ); | ||
|
||
$this->assertEqualSets( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also verify that the value is the same as we set in the settings. |
||
array( | ||
'ads_conversion_id', | ||
), | ||
array_keys( $ads->get_debug_fields() ) | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider template_redirect_data_provider | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed because it is already added to the class.