Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Tests\App\Service;
- use PHPUnit\Framework\TestCase;
- use Symfony\Contracts\HttpClient\ResponseInterface;
- use Symfony\Contracts\HttpClient\HttpClientInterface;
- /**
- * Class MixerServiceTest
- * @package Tests\App\Service
- */
- class MixerServiceTest extends TestCase
- {
- /**
- * Test GetData return array from calling the API
- */
- public function testGetData()
- {
- $httpClientMock = $this->getMockForAbstractClass(HttpClientInterface::class);
- $httpResponseMock = $this->getMockForAbstractClass(ResponseInterface::class);
- $httpResponseMock->method('toArray')->willReturn(['foo' => 'bar']);
- $httpClientMock->method('request')->willReturn($httpResponseMock);
- $mixerService = new \App\Service\MixerService($httpClientMock);
- $data = $mixerService->getData();
- $this->assertEquals($data, ['foo' => 'bar']);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment