@@ -93,6 +93,58 @@ public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError()
9393 $ this ->recaptcha_invisible ->htmlFormSnippet ();
9494 }
9595
96+ /**
97+ * @test
98+ */
99+ public function testSkipByIpAndReturnArrayReturnsDefaultArray ()
100+ {
101+
102+ $ mock = $ this ->getMockBuilder (ReCaptchaBuilder::class)
103+ ->setConstructorArgs ([
104+ "api_site_key " ,
105+ "api_secret_key "
106+ ])
107+ ->setMethods ([
108+ 'returnArray '
109+ ])
110+ ->getMock ();
111+
112+ $ mock ->method ('returnArray ' )
113+ ->willReturn (true );
114+
115+ $ this ->setSkipByIp ($ this ->recaptcha_v3 , true );
116+
117+ $ validate = $ this ->recaptcha_v3 ->validate ("" );
118+
119+ $ this ->assertEquals ([
120+ "skip_by_ip " => true ,
121+ "score " => 0.9 ,
122+ "success " => true
123+ ], $ validate );
124+ }
125+
126+ /**
127+ * @test
128+ */
129+ public function testSlipByIpReturnsValidResponse ()
130+ {
131+
132+ $ this ->setSkipByIp ($ this ->recaptcha_invisible , true );
133+ $ validate = $ this ->recaptcha_invisible ->validate ("" );
134+
135+ $ this ->assertTrue ($ validate );
136+ }
137+
138+ /**
139+ * @test
140+ * @expectedException \Exception
141+ */
142+ public function testReCaptchaInvisibleHtmlScriptTagJsApiShouldThrowError ()
143+ {
144+
145+ $ this ->recaptcha_invisible ->htmlScriptTagJsApi ();
146+ }
147+
96148 /**
97149 * @test
98150 */
@@ -114,6 +166,15 @@ public function testReCaptchaV2htmlFormButtonShouldThrowError()
114166 $ this ->recaptcha_v2 ->htmlFormButton ();
115167 }
116168
169+ protected function setSkipByIp (ReCaptchaBuilder $ builder , bool $ value )
170+ {
171+
172+ $ reflection = new \ReflectionClass ($ builder );
173+ $ reflection_property = $ reflection ->getProperty ('skip_by_ip ' );
174+ $ reflection_property ->setAccessible (true );
175+ $ reflection_property ->setValue ($ builder , $ value );
176+ }
177+
117178 /**
118179 * @inheritdoc
119180 */
0 commit comments