MockResponse example

/** * @internal * * @covers \Shopware\WebInstaller\Services\ReleaseInfoProvider */
class ReleaseInfoProviderTest extends TestCase
{
    public function testGetReleaseInfo(): void
    {
        $mockClient = new MockHttpClient([
            new MockResponse(json_encode([
                '6.5.0.0-rc1',
                '6.4.20.0',
                '6.4.19.0',
                '6.4.18.0',
                '6.4.12.0',
                '6.4.11.0',
                '6.3.5.0',
            ], \JSON_THROW_ON_ERROR)),
        ]);

        $releaseInfoProvider = new ReleaseInfoProvider($mockClient);

        
$client = new ApiClient(new MockHttpClient([]), true, '6.4.0.0', __DIR__);
        $version = $client->checkForUpdates();

        unset($_SERVER['SW_RECOVERY_NEXT_VERSION']);

        static::assertSame('6.4.1.0', $version->version);
    }

    public function testCheckUsingClient(): void
    {
        $responses = [
            new MockResponse('["6.5.0.0-rc1", "6.4.18.0", "6.4.17.0"]', ['Content-Type' => 'application/json']),
            new MockResponse('{"title": "Shopware", "body": "bla", "date": "2021-09-01", "version": "6.4.8.1", "fixedVulnerabilities": []}', ['Content-Type' => 'application/json']),
        ];

        $client = new ApiClient(new MockHttpClient($responses), true, '6.4.0.0', __DIR__);
        $version = $client->checkForUpdates();

        static::assertSame('6.4.8.1', $version->version);
    }

    public function testUnknownVersion(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.