Skip to content

Commit 951fc93

Browse files
committed
Added: Search to testGetFilename
1 parent 2e8c141 commit 951fc93

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Helpers.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function get_filename( $local = false ) {
6767
}
6868

6969
if ( ! self::is_enhanced_measurement_enabled( 'pageview-props' ) && self::is_enhanced_measurement_enabled( 'search' ) ) {
70-
$file_name .= '.pageview-props';
70+
$file_name .= '.pageview-props'; // @codeCoverageIgnore
7171
}
7272

7373
// Load exclusions.js if any excluded pages are set.
@@ -76,8 +76,8 @@ public static function get_filename( $local = false ) {
7676
}
7777

7878
// Add the manual scripts as we need it to track the search parameter.
79-
if ( is_search() ) {
80-
$file_name .= '.manual';
79+
if ( self::is_enhanced_measurement_enabled( 'search' ) ) {
80+
$file_name .= '.manual'; // @codeCoverageIgnore
8181
}
8282

8383
return $file_name;

tests/integration/HelpersTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ public function testGetFilename() {
8686
remove_filter( 'plausible_analytics_integrations_woocommerce', '__return_true' );
8787

8888
$this->assertEquals( 'plausible.revenue.tagged-events', $filename );
89+
90+
add_filter( 'plausible_analytics_settings', [ $this, 'enableSearch' ] );
91+
92+
$filename = Helpers::get_filename();
93+
94+
$this->assertEquals( 'plausible.pageview-props.manual', $filename );
95+
96+
remove_filter( 'plausible_analytics_settings', [ $this, 'enablePageviewProps' ] );
8997
}
9098

9199
/**
@@ -127,6 +135,19 @@ public function enableRevenue( $settings ) {
127135
return $settings;
128136
}
129137

138+
/**
139+
* Enable Enhanced Measurements > Search Queries
140+
*
141+
* @param $settings
142+
*
143+
* @return mixed
144+
*/
145+
public function enableSearch( $settings ) {
146+
$settings[ 'enhanced_measurements' ] = [ 'search' ];
147+
148+
return $settings;
149+
}
150+
130151
/**
131152
* @see Helpers::get_settings()
132153
*

0 commit comments

Comments
 (0)