44
55use  AlexWestergaard \PhpGa4 \UserProperty ;
66use  AlexWestergaard \PhpGa4 \Facade ;
7- use  AlexWestergaard \PhpGa4 \Exception \Ga4Exception ;
87use  AlexWestergaard \PhpGa4 \Event ;
98use  AlexWestergaard \PhpGa4 \Analytics ;
109use  AlexWestergaard \PhpGa4Test \TestCase ;
@@ -61,7 +60,7 @@ public function test_converts_to_full_microtime_stamp()
6160
6261    public  function  test_throws_if_microtime_older_than_three_days ()
6362    {
64-         $ this  ->expectException (Ga4Exception ::class);
63+         $ this  ->expectException (Facade \ Type \Ga4ExceptionType ::class);
6564        $ this  ->expectExceptionCode (Facade \Type \Ga4ExceptionType::MICROTIME_EXPIRED );
6665
6766        $ this  ->analytics ->setTimestampMicros (strtotime ('-1 week ' ));
@@ -106,16 +105,16 @@ public function test_exports_events_to_array()
106105
107106    public  function  test_throws_missing_measurement_id ()
108107    {
109-         $ this  ->expectException (Ga4Exception ::class);
110-         $ this  ->expectExceptionCode (Ga4Exception ::REQUEST_MISSING_MEASUREMENT_ID );
108+         $ this  ->expectException (Facade \ Type \Ga4ExceptionType ::class);
109+         $ this  ->expectExceptionCode (Facade \ Type \Ga4ExceptionType ::REQUEST_MISSING_MEASUREMENT_ID );
111110
112111        Analytics::new ('' , $ this  ->prefill ['api_secret ' ], true )->post ();
113112    }
114113
115114    public  function  test_throws_missing_apisecret ()
116115    {
117-         $ this  ->expectException (Ga4Exception ::class);
118-         $ this  ->expectExceptionCode (Ga4Exception ::REQUEST_MISSING_API_SECRET );
116+         $ this  ->expectException (Facade \ Type \Ga4ExceptionType ::class);
117+         $ this  ->expectExceptionCode (Facade \ Type \Ga4ExceptionType ::REQUEST_MISSING_API_SECRET );
119118
120119        Analytics::new ($ this  ->prefill ['measurement_id ' ], '' , true )->post ();
121120    }
@@ -128,8 +127,8 @@ public function test_throws_on_too_large_request_package()
128127            $ preparyKB  .= 'AAAAAAAA ' ; // 8 bytes 
129128        }
130129
131-         $ this  ->expectException (Ga4Exception ::class);
132-         $ this  ->expectExceptionCode (Ga4Exception ::REQUEST_TOO_LARGE );
130+         $ this  ->expectException (Facade \ Type \Ga4ExceptionType ::class);
131+         $ this  ->expectExceptionCode (Facade \ Type \Ga4ExceptionType ::REQUEST_TOO_LARGE );
133132
134133        $ userProperty  = UserProperty::new ()->setName ('large_package ' );
135134
@@ -141,4 +140,24 @@ public function test_throws_on_too_large_request_package()
141140
142141        $ this  ->analytics ->addUserProperty ($ userProperty )->post ();
143142    }
143+ 
144+     public  function  test_timeasmicro_throws_exceeding_max ()
145+     {
146+         $ time  = time () + 60 ;
147+ 
148+         $ this  ->expectException (Facade \Type \Ga4ExceptionType::class);
149+         $ this  ->expectExceptionCode (Facade \Type \Ga4ExceptionType::MICROTIME_EXPIRED );
150+ 
151+         $ this  ->analytics ->setTimestampMicros ($ time );
152+     }
153+ 
154+     public  function  test_timeasmicro_throws_exceeding_min ()
155+     {
156+         $ time  = strtotime ('-1 month ' );
157+ 
158+         $ this  ->expectException (Facade \Type \Ga4ExceptionType::class);
159+         $ this  ->expectExceptionCode (Facade \Type \Ga4ExceptionType::MICROTIME_EXPIRED );
160+ 
161+         $ this  ->analytics ->setTimestampMicros ($ time );
162+     }
144163}
0 commit comments