Skip to content

Commit 0e46ec9

Browse files
committed
Add testing case for is_connected(), as per CR feedback
1 parent 7429ace commit 0e46ec9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3+
namespace Yoast\WP\SEO\Tests\WP\Dashboard\Infrastructure\Analytics_4;
4+
5+
/**
6+
* Test class for the is_connected() method, when Site Kit is not active.
7+
*
8+
* @group analytics_4_adapter
9+
*
10+
* @requires PHP >= 7.4
11+
*
12+
* @covers Yoast\WP\SEO\Dashboard\Infrastructure\Analytics_4\Site_Kit_Analytics_4_Adapter::is_connected
13+
*
14+
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
15+
*/
16+
final class Analytics_4_Adapter_Is_Not_Connected_No_SiteKit_Test extends Abstract_Analytics_4_Adapter_Test {
17+
18+
/**
19+
* Let's not activate the Site Kit plugin for this test.
20+
*
21+
* @var string
22+
*/
23+
public $prereq_plugin_basename = '';
24+
25+
/**
26+
* Tests is_connected() returns false when Site Kit is not active, even if all the right values are in the DB.
27+
*
28+
* @return void
29+
*/
30+
public function test_is_not_connected() {
31+
$analytics_4_settings = [
32+
'accountID' => '123456789',
33+
'propertyID' => '12345',
34+
'webDataStreamID' => '1234',
35+
'measurementID' => 'G-123456789',
36+
];
37+
\update_option( 'googlesitekit_analytics-4_settings', $analytics_4_settings );
38+
39+
$is_connected = $this->instance->is_connected();
40+
41+
$this->assertFalse( $is_connected );
42+
}
43+
}

0 commit comments

Comments
 (0)