Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 078239d

Browse files
committed
do not use PHPUnit mock objects without configured expectations
1 parent 7d5fc82 commit 078239d

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Tests/RingCentralTransportTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Notifier\Bridge\RingCentral\Tests;
1313

1414
use Symfony\Component\HttpClient\MockHttpClient;
15+
use Symfony\Component\HttpClient\Response\MockResponse;
1516
use Symfony\Component\Notifier\Bridge\RingCentral\RingCentralOptions;
1617
use Symfony\Component\Notifier\Bridge\RingCentral\RingCentralTransport;
1718
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
@@ -60,14 +61,11 @@ public function testInvalidArgumentExceptionIsThrownIfFromIsInvalid(string $from
6061
public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from)
6162
{
6263
$message = new SmsMessage('+33612345678', 'Hello!');
63-
$response = $this->createMock(ResponseInterface::class);
64-
$response->expects(self::exactly(2))->method('getStatusCode')->willReturn(200);
65-
$response->expects(self::once())->method('getContent')->willReturn(json_encode(['id' => 'foo']));
66-
$client = new MockHttpClient(function (string $method, string $url) use ($response): ResponseInterface {
64+
$client = new MockHttpClient(function (string $method, string $url): ResponseInterface {
6765
self::assertSame('POST', $method);
6866
self::assertSame('https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/sms', $url);
6967

70-
return $response;
68+
return new MockResponse(json_encode(['id' => 'foo']));
7169
}
7270
);
7371
$transport = $this->createTransport($client, $from);

0 commit comments

Comments
 (0)