From 3c5dfa9a3d4f708a4e37a2ab000b2558c0acad3a Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Fri, 25 Jan 2019 21:14:49 -0500 Subject: [PATCH] Mock the HttpClient instead of making actual requests in tests --- test/Objects/ObjectsServiceTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Objects/ObjectsServiceTest.php b/test/Objects/ObjectsServiceTest.php index 9712a8b..bbf80ef 100644 --- a/test/Objects/ObjectsServiceTest.php +++ b/test/Objects/ObjectsServiceTest.php @@ -13,6 +13,7 @@ use ActivityPub\Database\PrefixNamingStrategy; use ActivityPub\Test\TestUtils\TestDateTimeProvider; use Doctrine\ORM\Tools\Setup; use GuzzleHttp\Client; +use GuzzleHttp\Psr7\Response; use PHPUnit\DbUnit\TestCaseTrait; class ObjectsServiceTest extends SQLiteTestCase @@ -44,7 +45,9 @@ class ObjectsServiceTest extends SQLiteTestCase 'objects-service.create' => new DateTime( "12:00" ), 'objects-service.update' => new DateTime( "12:01" ), ) ); - $this->httpClient = new Client( array( 'http_errors' => false ) ); + $this->httpClient = $this->createMock( Client::class ); + $this->httpClient->method( 'send' ) + ->willReturn( new Response( 404 ) ); $this->objectsService = new ObjectsService( $this->entityManager, $this->dateTimeProvider, $this->httpClient );