22
33namespace AlexWestergaard \PhpGa4Test \Unit ;
44
5+ use AlexWestergaard \PhpGa4 \Event \Login ;
56use AlexWestergaard \PhpGa4 \Helper \ConsentHelper ;
67use AlexWestergaard \PhpGa4Test \TestCase ;
78
89final class ConsentTest extends TestCase
910{
1011 public function test_no_consent_is_empty ()
1112 {
13+ $ this ->analytics ->addEvent (Login::new ());
14+
1215 $ export = $ this ->analytics ->consent ()->toArray ();
1316 $ this ->assertIsArray ($ export );
1417 $ this ->assertCount (0 , $ export );
1518 }
1619
1720 public function test_consent_ad_user_data_granted ()
1821 {
22+ $ this ->analytics ->addEvent (Login::new ());
23+
1924 $ this ->analytics ->consent ()->setAdUserDataPermission (true );
2025
2126 $ export = $ this ->analytics ->consent ()->toArray ();
@@ -28,6 +33,8 @@ public function test_consent_ad_user_data_granted()
2833
2934 public function test_consent_ad_personalization_granted ()
3035 {
36+ $ this ->analytics ->addEvent (Login::new ());
37+
3138 $ this ->analytics ->consent ()->setAdPersonalizationPermission (true );
3239
3340 $ export = $ this ->analytics ->consent ()->toArray ();
@@ -40,6 +47,8 @@ public function test_consent_ad_personalization_granted()
4047
4148 public function test_consent_granted ()
4249 {
50+ $ this ->analytics ->addEvent (Login::new ());
51+
4352 $ this ->analytics ->consent ()->setAdUserDataPermission (true );
4453 $ this ->analytics ->consent ()->setAdPersonalizationPermission (true );
4554
@@ -54,6 +63,8 @@ public function test_consent_granted()
5463
5564 public function test_consent_granted_posted ()
5665 {
66+ $ this ->analytics ->addEvent (Login::new ());
67+
5768 $ this ->analytics ->consent ()->setAdUserDataPermission (true );
5869 $ this ->analytics ->consent ()->setAdPersonalizationPermission (true );
5970
@@ -69,6 +80,8 @@ public function test_consent_granted_posted()
6980
7081 public function test_consent_ad_user_data_denied ()
7182 {
83+ $ this ->analytics ->addEvent (Login::new ());
84+
7285 $ this ->analytics ->consent ()->setAdUserDataPermission (false );
7386
7487 $ export = $ this ->analytics ->consent ()->toArray ();
@@ -81,6 +94,8 @@ public function test_consent_ad_user_data_denied()
8194
8295 public function test_consent_ad_personalization_denied ()
8396 {
97+ $ this ->analytics ->addEvent (Login::new ());
98+
8499 $ this ->analytics ->consent ()->setAdPersonalizationPermission (false );
85100
86101 $ export = $ this ->analytics ->consent ()->toArray ();
@@ -93,6 +108,8 @@ public function test_consent_ad_personalization_denied()
93108
94109 public function test_consent_denied ()
95110 {
111+ $ this ->analytics ->addEvent (Login::new ());
112+
96113 $ this ->analytics ->consent ()->setAdUserDataPermission (false );
97114 $ this ->analytics ->consent ()->setAdPersonalizationPermission (false );
98115
@@ -107,6 +124,8 @@ public function test_consent_denied()
107124
108125 public function test_consent_denied_posted ()
109126 {
127+ $ this ->analytics ->addEvent (Login::new ());
128+
110129 $ this ->analytics ->consent ()->setAdUserDataPermission (false );
111130 $ this ->analytics ->consent ()->setAdPersonalizationPermission (false );
112131
0 commit comments