| 1 |
<?php |
| 2 |
|
| 3 |
namespace cybot\cookiebot\tests\integration\addons; |
| 4 |
|
| 5 |
use cybot\cookiebot\addons\controller\addons\wp_google_analytics_events\Wp_Google_Analytics_Events; |
| 6 |
use PHPUnit\Framework\ExpectationFailedException; |
| 7 |
use SebastianBergmann\RecursionContext\InvalidArgumentException; |
| 8 |
use WP_UnitTestCase; |
| 9 |
|
| 10 |
class Test_Wp_Google_Analytics_Events extends WP_UnitTestCase { |
| 11 |
|
| 12 |
/** |
| 13 |
* @covers \cybot\cookiebot\addons\controller\addons\wp_google_analytics_events\Wp_Google_Analytics_Events |
| 14 |
* @throws ExpectationFailedException |
| 15 |
* @throws InvalidArgumentException |
| 16 |
* @throws \Exception |
| 17 |
*/ |
| 18 |
public function test_is_plugin_compatible() { |
| 19 |
$content = Wp_Google_Analytics_Events::get_svn_file_content(); |
| 20 |
|
| 21 |
$wp_head_snippet = <<<TEXT |
| 22 |
add_action('wp_head', |
| 23 |
array('GAESnippets', 'add_snippet_to_header'), |
| 24 |
0); |
| 25 |
TEXT; |
| 26 |
|
| 27 |
$required_code_snippets = array( |
| 28 |
"wp_register_script('ga_events_frontend_bundle',", |
| 29 |
"wp_localize_script('ga_events_frontend_bundle',", |
| 30 |
"wp_enqueue_script('ga_events_frontend_bundle');", |
| 31 |
"wp_register_script('ga_events_main_script',", |
| 32 |
"wp_localize_script('ga_events_main_script',", |
| 33 |
"wp_enqueue_script('ga_events_main_script');", |
| 34 |
$wp_head_snippet, |
| 35 |
); |
| 36 |
|
| 37 |
foreach ( $required_code_snippets as $required_code_snippet ) { |
| 38 |
$this->assertNotFalse( strpos( $content, $required_code_snippet ) ); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|