alreadyInstalled example

public function getDecorated(): AbstractAppLifecycle
    {
        throw new DecorationPatternException(self::class);
    }

    public function install(Manifest $manifest, bool $activate, Context $context): void
    {
        $this->ensureIsCompatible($manifest);

        $app = $this->loadAppByName($manifest->getMetadata()->getName()$context);
        if ($app) {
            throw AppException::alreadyInstalled($manifest->getMetadata()->getName());
        }

        $defaultLocale = $this->getDefaultLocale($context);
        $metadata = $manifest->getMetadata()->toArray($defaultLocale);
        $appId = Uuid::randomHex();
        $roleId = Uuid::randomHex();
        $metadata = $this->enrichInstallMetadata($manifest$metadata$roleId);

        $app = $this->updateApp($manifest$metadata$appId$roleId$defaultLocale$context, true);

        $event = new AppInstalledEvent($app$manifest$context);
        
/** * @internal * * @covers \Shopware\Core\Framework\App\Exception\AppAlreadyInstalledException */
class AppAlreadyInstalledExceptionTest extends TestCase
{
    public function testException(): void
    {
        $appName = 'test_app';
        $exception = AppException::alreadyInstalled($appName);

        static::assertInstanceOf(AppAlreadyInstalledException::class$exception);

        static::assertSame(
            'App "test_app" is already installed',
            $exception->getMessage()
        );

        static::assertSame(
            ['appName' => $appName],
            $exception->getParameters()
        );
public function testNotFound(): void
    {
        $e = AppException::notFound('NonExistingApp');

        static::assertInstanceOf(AppNotFoundException::class$e);
        static::assertEquals(AppException::NOT_FOUND, $e->getErrorCode());
    }

    public function testAlreadyInstalled(): void
    {
        $e = AppException::alreadyInstalled('AlreadyInstalledApp');

        static::assertInstanceOf(AppAlreadyInstalledException::class$e);
        static::assertEquals(AppException::ALREADY_INSTALLED, $e->getErrorCode());
    }

    public function testRegistrationFailed(): void
    {
        $e = AppException::registrationFailed('ToBeRegisteredApp', 'Invalid signature');

        static::assertEquals(AppException::REGISTRATION_FAILED, $e->getErrorCode());
        static::assertEquals('App registration for "ToBeRegisteredApp" failed: Invalid signature', $e->getMessage());
    }
Home | Imprint | This part of the site doesn't use cookies.