@@ -367,7 +367,7 @@ public function testIPv6NotationsCaching()
367367 // Replace the real Guzzle client with our mock
368368 $ reflectionClass = new \ReflectionClass ($ h );
369369 $ reflectionProperty = $ reflectionClass ->getProperty ('http_client ' );
370- $ reflectionProperty -> setAccessible ( true );
370+
371371 $ reflectionProperty ->setValue ($ h , $ mock_guzzle );
372372
373373 // Different notations of the same IPv6 address
@@ -415,26 +415,26 @@ public function testResproxy()
415415 $ h = new IPinfo ("test_token " );
416416 $ ip = "175.107.211.204 " ;
417417
418- // Create a mock stream for the response body
419- $ mockStream = $ this ->createMock (\Psr \Http \Message \StreamInterface::class);
418+ // Create a stub stream for the response body
419+ $ mockStream = $ this ->createStub (\Psr \Http \Message \StreamInterface::class);
420420 $ mockStream ->method ("__toString " )->willReturn (json_encode ([
421421 "ip " => "175.107.211.204 " ,
422422 "last_seen " => "2025-01-20 " ,
423423 "percent_days_seen " => 0.85 ,
424424 "service " => "example_service "
425425 ]));
426426
427- $ mockResponse = $ this ->createMock (\GuzzleHttp \Psr7 \Response::class);
427+ $ mockResponse = $ this ->createStub (\GuzzleHttp \Psr7 \Response::class);
428428 $ mockResponse ->method ("getStatusCode " )->willReturn (200 );
429429 $ mockResponse ->method ("getBody " )->willReturn ($ mockStream );
430430
431- $ mockClient = $ this ->createMock (\GuzzleHttp \Client::class);
431+ $ mockClient = $ this ->createStub (\GuzzleHttp \Client::class);
432432 $ mockClient ->method ("request " )->willReturn ($ mockResponse );
433433
434434 // Use reflection to replace the http_client
435435 $ reflectionClass = new \ReflectionClass ($ h );
436436 $ reflectionProperty = $ reflectionClass ->getProperty ("http_client " );
437- $ reflectionProperty -> setAccessible ( true );
437+
438438 $ reflectionProperty ->setValue ($ h , $ mockClient );
439439
440440 $ res = $ h ->getResproxy ($ ip );
@@ -448,21 +448,21 @@ public function testResproxyEmpty()
448448 {
449449 $ h = new IPinfo ("test_token " );
450450
451- // Create a mock stream for the response body
452- $ mockStream = $ this ->createMock (\Psr \Http \Message \StreamInterface::class);
451+ // Create a stub stream for the response body
452+ $ mockStream = $ this ->createStub (\Psr \Http \Message \StreamInterface::class);
453453 $ mockStream ->method ("__toString " )->willReturn ("{} " );
454454
455- $ mockResponse = $ this ->createMock (\GuzzleHttp \Psr7 \Response::class);
455+ $ mockResponse = $ this ->createStub (\GuzzleHttp \Psr7 \Response::class);
456456 $ mockResponse ->method ("getStatusCode " )->willReturn (200 );
457457 $ mockResponse ->method ("getBody " )->willReturn ($ mockStream );
458458
459- $ mockClient = $ this ->createMock (\GuzzleHttp \Client::class);
459+ $ mockClient = $ this ->createStub (\GuzzleHttp \Client::class);
460460 $ mockClient ->method ("request " )->willReturn ($ mockResponse );
461461
462462 // Use reflection to replace the http_client
463463 $ reflectionClass = new \ReflectionClass ($ h );
464464 $ reflectionProperty = $ reflectionClass ->getProperty ("http_client " );
465- $ reflectionProperty -> setAccessible ( true );
465+
466466 $ reflectionProperty ->setValue ($ h , $ mockClient );
467467
468468 $ res = $ h ->getResproxy ("8.8.8.8 " );
0 commit comments