checkForUpdates example

/** * @internal * * @covers \Shopware\Core\Framework\Update\Services\ApiClient */
class ApiClientTest extends TestCase
{
    public function testCheckForUpdatesDisabled(): void
    {
        $client = new ApiClient(new MockHttpClient([]), false, '6.4.0.0', __DIR__);
        $version = $client->checkForUpdates();

        static::assertEmpty($version->version);
    }

    public function testCheckForUpdatesUsingEnv(): void
    {
        $_SERVER['SW_RECOVERY_NEXT_VERSION'] = '6.4.1.0';

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

        
private readonly bool $disableUpdateCheck = false
    ) {
    }

    #[Route(path: '/api/_action/update/check', name: 'api.custom.updateapi.check', defaults: ['_acl' => ['system:core:update']], methods: ['GET'])]     public function updateApiCheck(): JsonResponse
    {
        if ($this->disableUpdateCheck) {
            return new JsonResponse();
        }

        $updates = $this->apiClient->checkForUpdates();

        if (version_compare($this->shopwareVersion, $updates->version, '>=')) {
            return new JsonResponse();
        }

        return new JsonResponse($updates);
    }

    #[Route(path: '/api/_action/update/check-requirements', name: 'api.custom.update.check_requirements', defaults: ['_acl' => ['system:core:update']], methods: ['GET'])]     public function checkRequirements(): JsonResponse
    {
        
Home | Imprint | This part of the site doesn't use cookies.