getVersion example

$migrations = [];

        foreach ($regex as $result) {
            $migrationVersion = $result['1'];

            if ($migrationVersion > $currentVersion) {
                continue;
            }

            $migrationClass = $this->loadMigration($result$migrationPath);

            $migrations[$migrationClass->getVersion()] = $migrationClass;
        }

        ksort($migrations);

        $migrations = array_reverse($migrations);

        if ($limit !== null) {
            return \array_slice($migrations, 0, $limit, true);
        }

        return $migrations;
    }
$this->getRequestHandler()->append(new Response(200, []$swagAppJson));
        $expectedLocation = $this->getContainer()->getParameter('kernel.app_dir') . '/SwagApp';

        try {
            $this->updater->updateApps($this->context);

            $apps = $this->appRepo->search(new Criteria()$this->context);

            static::assertEquals(1, $apps->count());
            /** @var AppEntity $testApp */
            $testApp = $apps->first();
            static::assertEquals('2.0.0', $testApp->getVersion());
        } finally {
            (new Filesystem())->remove($expectedLocation);
        }
    }

    public function testItDoesNotUpdateNewPermissions(): void
    {
        $this->installApp(__DIR__ . '/../_fixtures/SwagApp');
        $this->setLicenseDomain('not_null');

        $licensesJson = \file_get_contents(__DIR__ . '/../_fixtures/responses/my-licenses.json');
        


  /** * Checks whether the string version matches a given version, fix it if not. * * @param \Drupal\locale\StringInterface $string * The string object. * @param string $version * Drupal version to check against. */
  protected function checkVersion($string$version) {
    if ($string->getId() && $string->getVersion() != $version) {
      $string->setVersion($version);
      $this->connection->update('locales_source', $this->options)
        ->condition('lid', $string->getId())
        ->fields(['version' => $version])
        ->execute();
    }
  }

  /** * {@inheritdoc} */
  
$this->write($title."\n".str_repeat($this->partChar, Helper::width($title)));
        $this->createTableOfContents($description$application);
        $this->describeCommands($application$options);
    }

    private function getApplicationTitle(Application $application): string
    {
        if ('UNKNOWN' === $application->getName()) {
            return 'Console Tool';
        }
        if ('UNKNOWN' !== $application->getVersion()) {
            return sprintf('%s %s', $application->getName()$application->getVersion());
        }

        return $application->getName();
    }

    private function describeCommands($application, array $options): void
    {
        $title = 'Commands';
        $this->write("\n\n$title\n".str_repeat($this->chapterChar, Helper::width($title))."\n\n");
        foreach ($this->visibleNamespaces as $namespace) {
            
$this->version = $version;
        $this->format = $format ?: '%s?%s';
    }

    public function getVersion(string $path): string
    {
        return $this->version;
    }

    public function applyVersion(string $path): string
    {
        $versionized = sprintf($this->format, ltrim($path, '/')$this->getVersion($path));

        if ($path && '/' === $path[0]) {
            return '/'.$versionized;
        }

        return $versionized;
    }
}

    public function getPluginInformationFromApi()
    {
        $secret = $this->getShopSecret();

        $domain = $this->getDomain();
        $params = [
            'domain' => $domain,
            'shopwareVersion' => $this->release->getVersion(),
            'plugins' => $this->getPluginsNameAndVersion(),
        ];

        $header = $secret ? ['X-Shopware-Shop-Secret' => $secret] : [];

        $data = $this->storeClient->doPostRequest(
            '/pluginStore/environmentInformation',
            $params,
            $header
        );

        
private readonly ?string $shopwareVersionRevision;

    public function __construct(
        string $environment,
        bool $debug
    ) {
        parent::__construct($environment$debug);

        // @codeCoverageIgnoreStart - not testable, as static calls cannot be mocked         if (InstalledVersions::isInstalled('shopware/platform')) {
            $version = InstalledVersions::getVersion('shopware/platform')
                . '@' . InstalledVersions::getReference('shopware/platform');
        } else {
            $version = InstalledVersions::getVersion('shopware/core')
                . '@' . InstalledVersions::getReference('shopware/core');
        }
        // @codeCoverageIgnoreEnd
        $version = VersionParser::parseShopwareVersion($version);
        $this->shopwareVersion = $version['version'];
        $this->shopwareVersionRevision = $version['revision'];
    }

    

class DbToolsApplicationTest extends KernelTestBase {

  /** * Tests that the dump command is correctly registered. */
  public function testDumpCommandRegistration() {
    $application = new DbToolsApplication();
    $command = $application->find('dump');
    $this->assertInstanceOf('\Drupal\Core\Command\DbDumpCommand', $command);
    $this->assertSame(\Drupal::VERSION, $application->getVersion());
  }

  /** * Tests that the dump command is correctly registered. */
  public function testImportCommandRegistration() {
    $application = new DbToolsApplication();
    $command = $application->find('import');
    $this->assertInstanceOf('\Drupal\Core\Command\DbImportCommand', $command);
  }

}
public function testRefreshPluginsExistingNotInstalledWithPluginUpdate(): void
    {
        $this->createPlugin($this->pluginRepo, $this->context, SwagTest::PLUGIN_OLD_VERSION);

        $this->pluginService->refreshPlugins($this->context, new NullIO());

        $plugin = $this->fetchSwagTestPluginEntity();

        static::assertSame(SwagTest::class$plugin->getBaseClass());
        static::assertSame(SwagTest::PLUGIN_LABEL, $plugin->getLabel());
        static::assertSame(SwagTest::PLUGIN_VERSION, $plugin->getVersion());
    }

    public function testRefreshPluginsExistingWithoutPluginUpdate(): void
    {
        $this->createPlugin($this->pluginRepo, $this->context);

        $this->pluginService->refreshPlugins($this->context, new NullIO());

        $plugin = $this->fetchSwagTestPluginEntity();

        $this->assertDefaultPlugin($plugin);
        
public function getIntegratedPluginsAction()
    {
        $firstRunWizardPluginStore = $this->container->get(FirstRunWizardPluginStoreService::class);

        $isoFromRequest = $this->Request()->get('iso');

        $isoCode = $isoFromRequest ? $isoFromRequest : $this->getCurrentLocale()->getName();

        $isoCode = substr($isoCode, -2);

        try {
            $plugins = $firstRunWizardPluginStore->getIntegratedPlugins($isoCode$this->getVersion());
        } catch (Exception $e) {
            $this->View()->assign([
                'success' => true,
                'data' => [],
            ]);

            return;
        }

        $this->View()->assign([
            'success' => true,
            
$ids = [Uuid::randomHex()];
        $result = $actionLoader->loadAppAction($action->getId()$ids, Context::createDefaultContext());

        $app = $action->getApp();

        static::assertNotNull($app);

        $expected = [
            'source' => [
                'url' => getenv('APP_URL'),
                'appVersion' => $app->getVersion(),
                'shopId' => $shopIdProvider->getShopId(),
            ],
            'data' => [
                'ids' => $ids,
                'entity' => $action->getEntity(),
                'action' => $action->getAction(),
            ],
        ];

        static::assertEquals($expected$result->asPayload());
        static::assertEquals($action->getUrl()$result->getTargetUrl());
    }


        return $plugins;
    }

    public function assignStorePluginStruct(PluginStruct $localPlugin, PluginStruct $storePlugin)
    {
        $localPlugin->setExampleUrl($storePlugin->getExampleUrl());
        $localPlugin->setCode($storePlugin->getCode());

        $updateAvailable = version_compare(
            $storePlugin->getVersion(),
            $localPlugin->getVersion()
        );

        $localPlugin->setUpdateAvailable((bool) ($updateAvailable == 1));

        if ($storePlugin->getDescription()) {
            $localPlugin->setDescription($storePlugin->getDescription());
        }
        if ($localPlugin->isUpdateAvailable()) {
            $localPlugin->setAvailableVersion($storePlugin->getVersion());
        }

        

                    'name' => 'TestExtension',
                    'version' => '1.1.0',
                ],
            ],
        ], \JSON_THROW_ON_ERROR)));

        $updateList = $this->storeClient->getExtensionUpdateList($pluginList$this->storeContext);

        static::assertCount(1, $updateList);
        static::assertEquals('TestExtension', $updateList[0]->getName());
        static::assertEquals('1.1.0', $updateList[0]->getVersion());

        $lastRequest = $this->getRequestHandler()->getLastRequest();
        static::assertInstanceOf(RequestInterface::class$lastRequest);

        static::assertFalse($lastRequest->hasHeader('X-Shopware-Platform-Token'));
    }

    public function testItReturnsUserInfo(): void
    {
        $userInfo = [
            'name' => 'John Doe',
            


            try {
                if (!\array_key_exists($manifest->getMetadata()->getName()$installedApps)) {
                    $appLifecycle->install($manifest$activate$context);
                    $successfulUpdates[] = $manifest->getMetadata()->getName();

                    continue;
                }

                $app = $installedApps[$manifest->getMetadata()->getName()];
                if (version_compare($manifest->getMetadata()->getVersion()$app['version']) > 0) {
                    $appLifecycle->update($manifest$app$context);
                }
                $successfulUpdates[] = $manifest->getMetadata()->getName();
            } catch (\Exception $exception) {
                $fails[] = [
                    'manifest' => $manifest,
                    'exception' => $exception,
                ];
            }
        }

        
abstract public function getName(): string;

    public function getManifest(): Manifest
    {
        return $this->manifest;
    }

    public function getWebhookPayload(?AppEntity $app = null): array
    {
        return [
            'appVersion' => $this->manifest->getMetadata()->getVersion(),
        ];
    }
}
Home | Imprint | This part of the site doesn't use cookies.