getRequestsCount example

use Symfony\Contracts\HttpClient\ChunkInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class MockHttpClientTest extends HttpClientTestCase
{
    /** * @dataProvider mockingProvider */
    public function testMocking($factory, array $expectedResponses)
    {
        $client = new MockHttpClient($factory);
        $this->assertSame(0, $client->getRequestsCount());

        $urls = ['/foo', '/bar'];
        foreach ($urls as $i => $url) {
            $response = $client->request('POST', $url['body' => 'payload']);
            $this->assertEquals($expectedResponses[$i]$response->getContent());
        }

        $this->assertSame(2, $client->getRequestsCount());
    }

    public static function mockingProvider(): iterable
    {
public function testDownloadRecoveryToolDoesNothing(): void
    {
        $_SERVER['SW_RECOVERY_NEXT_VERSION'] = '6.4.0.0';

        $httpClient = new MockHttpClient([]);
        $client = new ApiClient($httpClient, true, '6.4.0.0', __DIR__);

        $client->downloadRecoveryTool();

        unset($_SERVER['SW_RECOVERY_NEXT_VERSION']);
        static::assertSame(0, $httpClient->getRequestsCount());
    }

    public function testDownloadRecoveryTool(): void
    {
        $responses = [
            new MockResponse('test', ['Content-Type' => 'application/json']),
        ];

        $fs = new Filesystem();
        $fs->mkdir(__DIR__ . '/public');

        
Home | Imprint | This part of the site doesn't use cookies.