Version example


    public function testGetExtension(string $file, string $statusName, ?string $statusColor): void
    {
        $storeClient = $this->createMock(StoreClient::class);
        $storeClient->method('getExtensionCompatibilities')->willReturn(json_decode((string) file_get_contents($file), true, 512, \JSON_THROW_ON_ERROR));

        $pluginCompatibility = new ExtensionCompatibility(
            $storeClient,
            $this->getExtensionDataProvider()
        );

        $version = new Version();
        $version->assign([
            'version' => '6.6.0.0',
        ]);

        $getExtensionCompatibilities = $pluginCompatibility->getExtensionCompatibilities($version, Context::createDefaultContext());

        static::assertSame($statusName$getExtensionCompatibilities[0]['statusName']);
        static::assertSame($statusColor$getExtensionCompatibilities[0]['statusColor']);
    }

    /** * @return iterable<string, array{0: string, 1: string, 2: string|null}> */
use Shopware\Core\System\SystemConfig\SystemConfigService;

/** * @internal * * @covers \Shopware\Core\Framework\Update\Steps\DeactivateExtensionsStep */
class DeactivateExtensionsStepTest extends TestCase
{
    public function testRunWithEmptyPlugins(): void
    {
        $version = new Version();
        $version->assign([
            'version' => '6.6.0.0',
        ]);

        $deactivateExtensionsStep = new DeactivateExtensionsStep(
            $version,
            ExtensionCompatibility::PLUGIN_DEACTIVATION_FILTER_ALL,
            $this->createMock(ExtensionCompatibility::class),
            $this->createMock(ExtensionLifecycleService::class),
            $this->createMock(SystemConfigService::class),
            Context::createDefaultContext()
        );

    private function createVersionFromGithubResponse(string $shopwareVersion, array $releaseInformation): Version
    {
        $latestRelease = $this->getRelease($shopwareVersion$releaseInformation);

        $installPackage = $this->getUpdatePackage($latestRelease['assets']);

        $parts = explode('_', $installPackage['name']);
        $sha1 = array_pop($parts);

        return new Version([
            'version' => $latestRelease['tag_name'],
            'release_date' => $latestRelease['created_at'],
            'size' => $installPackage['size'],
            'uri' => $installPackage['browser_download_url'],
            'changelog' => $latestRelease['html_url'],
            'isNewer' => true,
            'security_update' => str_contains(self::SECURITY_IDENTIFIER, $latestRelease['body']),
            'sha1' => str_replace('.zip', '', $sha1),
        ]);
    }

    
$this->httpClient = $httpClient;
    }

    /** * @return FinishResult|ValidResult */
    public function downloadRange(RangeDownloadRequest $request)
    {
        // Load SwagUpdate so the DownloadStep can be auto-loaded         Shopware()->Plugins()->Backend()->SwagUpdate();

        $version = new Version([
            'uri' => $request->getUri(),
            'size' => $request->getSize(),
            'sha1' => $request->getSha1(),
        ]);

        return (new DownloadStep($version$request->getDestination()))->run($request->getOffset());
    }

    /** * @param string $file * @param string $pluginName * * @throws Exception */
private readonly HttpClientInterface $client,
        private readonly bool $shopwareUpdateEnabled,
        private readonly string $shopwareVersion,
        private readonly string $projectDir
    ) {
    }

    public function checkForUpdates(): Version
    {
        $fakeVersion = EnvironmentHelper::getVariable('SW_RECOVERY_NEXT_VERSION');
        if (\is_string($fakeVersion)) {
            return new Version([
                'version' => $fakeVersion,
                'title' => 'Shopware ' . $fakeVersion,
                'body' => 'This is a fake version for testing purposes',
                'date' => new \DateTimeImmutable(),
                'fixedVulnerabilities' => [],
            ]);
        }

        if (!$this->shopwareUpdateEnabled) {
            return new Version();
        }

        

class UpdateControllerTest extends TestCase
{
    public function testCheckForUpdatesNoUpdate(): void
    {
        $apiClient = $this->createMock(ApiClient::class);
        $apiClient
            ->method('checkForUpdates')
            ->willReturn(new Version(['version' => '6.5.1.0', 'date' => '2020-01-01']));

        $updateController = new UpdateController(
            $apiClient,
            $this->createMock(WriteableCheck::class),
            $this->createMock(LicenseCheck::class),
            $this->createMock(ExtensionCompatibility::class),
            $this->createMock(EventDispatcherInterface::class),
            $this->createMock(SystemConfigService::class),
            $this->createMock(AbstractExtensionLifecycle::class),
            '6.5.1.0'
        );

        
use Shopware\Core\Framework\Update\Struct\Version;

/** * @internal * * @covers \Shopware\Core\Framework\Update\Struct\Version */
class VersionTest extends TestCase
{
    public function testEmptyConstructor(): void
    {
        $version = new Version();
        static::assertSame('', $version->title);
        static::assertSame('', $version->body);
        static::assertSame('', $version->version);
        static::assertSame([]$version->fixedVulnerabilities);

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

    public function testFillConstructor(): void
    {
        $vuln = ['severity' => 'severity', 'summary' => 'summary', 'link' => 'link'];
        
Home | Imprint | This part of the site doesn't use cookies.