@@ -121,9 +121,41 @@ function test_evaluate()
121121 $ this ->assertFalse ( QueueIT \KnownUserV3 \SDK \CookieValidatorHelper::evaluate ($ triggerPart ,array ("c2 " =>"ddd " ,"c1 " =>"1 " )));
122122
123123 }
124+ }
124125
126+ class UserAgentValidatorHelperTest extends UnitTestCase
127+ {
128+ function test_evaluate () {
129+ $ triggerPart = array ();
130+ $ triggerPart ["Operator " ] = "Contains " ;
131+ $ triggerPart ["IsIgnoreCase " ] = false ;
132+ $ triggerPart ["IsNegative " ] = false ;
133+ $ triggerPart ["ValueToCompare " ] = "googlebot " ;
134+ $ this ->assertFalse ( QueueIT \KnownUserV3 \SDK \UserAgentValidatorHelper::evaluate ($ triggerPart , "Googlebot sample useraagent " ));
135+
136+ $ triggerPart = array ();
137+ $ triggerPart ["Operator " ] = "Equals " ;
138+ $ triggerPart ["ValueToCompare " ] = "googlebot " ;
139+ $ triggerPart ["IsIgnoreCase " ] = true ;
140+ $ triggerPart ["IsNegative " ] = true ;
141+ $ this ->assertTrue ( QueueIT \KnownUserV3 \SDK \UserAgentValidatorHelper::evaluate ($ triggerPart ,"oglebot sample useraagent " ));
125142
143+ $ triggerPart = array ();
144+ $ triggerPart ["Operator " ] = "Contains " ;
145+ $ triggerPart ["ValueToCompare " ] = "googlebot " ;
146+ $ triggerPart ["IsIgnoreCase " ] = false ;
147+ $ triggerPart ["IsNegative " ] = true ;
148+ $ this ->assertFalse ( QueueIT \KnownUserV3 \SDK \UserAgentValidatorHelper::evaluate ($ triggerPart , "googlebot " ));
149+
150+ $ triggerPart = array ();
151+ $ triggerPart ["Operator " ] = "Contains " ;
152+ $ triggerPart ["ValueToCompare " ] = "googlebot " ;
153+ $ triggerPart ["IsIgnoreCase " ] = true ;
154+ $ triggerPart ["IsNegative " ] = false ;
155+ $ this ->assertTrue ( QueueIT \KnownUserV3 \SDK \UserAgentValidatorHelper::evaluate ($ triggerPart , "Googlebot " ));
156+ }
126157}
158+
127159class IntegrationEvaluatorTest extends UnitTestCase
128160{
129161 function test_getMatchedIntegrationConfig_OneTrigger_And_NotMatched ()
@@ -163,9 +195,9 @@ function test_getMatchedIntegrationConfig_OneTrigger_And_NotMatched()
163195 $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
164196 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
165197
166- $ this ->assertTrue ( $ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url , array ()) === null );
167-
198+ $ this ->assertTrue ( $ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url , array (), "" ) === null );
168199 }
200+
169201 function test_getMatchedIntegrationConfig_OneTrigger_And_Matched ()
170202 {
171203
@@ -204,7 +236,55 @@ function test_getMatchedIntegrationConfig_OneTrigger_And_Matched()
204236 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
205237
206238 $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig ,
207- $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ))["Name " ]==="integration1 " );
239+ $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ),"" )["Name " ]==="integration1 " );
240+ }
241+
242+ function test_getMatchedIntegrationConfig_OneTrigger_And_NotMatched_UserAgent ()
243+ {
244+
245+ $ integrationConfig = array (
246+ "Integrations " =>array (
247+ array (
248+ "Name " =>"integration1 " ,
249+ "Triggers " => array (
250+ array (
251+ "LogicalOperator " =>"And " ,
252+ "TriggerParts " =>array (
253+ array (
254+ "CookieName " =>"c1 " ,
255+ "Operator " =>"Equals " ,
256+ "ValueToCompare " =>"value1 " ,
257+ "ValidatorType " => "CookieValidator " ,
258+ "IsIgnoreCase " =>true ,
259+ "IsNegative " =>false
260+ ),
261+ array (
262+ "UrlPart " => "PageUrl " ,
263+ "ValidatorType " => "UrlValidator " ,
264+ "ValueToCompare " => "test " ,
265+ "Operator " =>"Contains " ,
266+ "IsIgnoreCase " =>false ,
267+ "IsNegative " =>false
268+ ),
269+ array (
270+ "ValidatorType " => "UserAgentValidator " ,
271+ "ValueToCompare " => "googlebot " ,
272+ "Operator " =>"Contains " ,
273+ "IsIgnoreCase " =>true ,
274+ "IsNegative " =>true
275+ )
276+ )
277+ )
278+ )
279+ )
280+ )
281+ );
282+
283+ $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
284+ $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
285+
286+ $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig ,
287+ $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ),"bot.html google.com googlebot test " )==NULL );
208288 }
209289
210290
@@ -245,10 +325,11 @@ function test_getMatchedIntegrationConfig_OneTrigger_Or_NotMatched()
245325 $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
246326 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
247327
248- $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ))==null );
328+ $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ), "" )==null );
249329
250330 }
251331
332+
252333 function test_getMatchedIntegrationConfig_OneTrigger_Or_Matched ()
253334 {
254335
@@ -286,7 +367,8 @@ function test_getMatchedIntegrationConfig_OneTrigger_Or_Matched()
286367 $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
287368 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
288369
289- $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ))["Name " ]==="integration1 " );
370+ $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig ,
371+ $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ),"" )["Name " ]==="integration1 " );
290372
291373 }
292374 function test_getMatchedIntegrationConfig_TwoTriggers_Matched ()
@@ -341,7 +423,8 @@ function test_getMatchedIntegrationConfig_TwoTriggers_Matched()
341423 $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
342424 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
343425
344- $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ))["Name " ]=="integration1 " );
426+ $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig , $ url ,
427+ array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ),"" )["Name " ]=="integration1 " );
345428
346429 }
347430 function test_getMatchedIntegrationConfig_ThreeIntegrationsInOrder_SecondMatched ()
@@ -409,7 +492,8 @@ function test_getMatchedIntegrationConfig_ThreeIntegrationsInOrder_SecondMatched
409492 $ url = "http://test.tesdomain.com:8080/test?q=2 " ;
410493 $ testObject = new QueueIT \KnownUserV3 \SDK \IntegrationEvaluator ();
411494
412- $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig ,$ url ,array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ))["Name " ]=="integration1 " );
495+ $ this ->assertTrue ($ testObject ->getMatchedIntegrationConfig ($ integrationConfig ,$ url ,
496+ array ("c2 " =>"ddd " ,"c1 " =>"Value1 " ),"" )["Name " ]=="integration1 " );
413497 }
414498
415499}
0 commit comments