AppUpdatedEvent example

use Shopware\Core\Framework\Webhook\AclPrivilegeCollection;

/** * @internal */
class AppUpdatedEventTest extends TestCase
{
    public function testGetter(): void
    {
        $app = new AppEntity();
        $context = Context::createDefaultContext();
        $event = new AppUpdatedEvent(
            $app,
            Manifest::createFromXmlFile(__DIR__ . '/../Manifest/_fixtures/test/manifest.xml'),
            $context
        );

        static::assertEquals($app$event->getApp());
        static::assertInstanceOf(Manifest::class$event->getManifest());
        static::assertEquals($context$event->getContext());
        static::assertEquals(AppUpdatedEvent::NAME, $event->getName());
        static::assertEquals([
            'appVersion' => '1.0.0',
        ],
static::assertCount(1, $themes);
        static::assertTrue($themes->first()->isActive());
    }

    public function testHandleUpdateIfNotActivated(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/fixtures/Apps/theme', false);
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/fixtures/Apps/theme/manifest.xml');

        $this->eventDispatcher->dispatch(
            new AppUpdatedEvent(
                (new AppEntity())->assign([
                    'active' => false,
                    'name' => 'SwagTheme',
                    'path' => str_replace(
                        $this->getContainer()->getParameter('kernel.project_dir') . '/',
                        '',
                        $manifest->getPath()
                    ),
                ]),
                $manifest,
                Context::createDefaultContext()
            )
/** * @param array{id: string, roleId: string} $app */
    public function update(Manifest $manifest, array $app, Context $context): void
    {
        $this->ensureIsCompatible($manifest);

        $defaultLocale = $this->getDefaultLocale($context);
        $metadata = $manifest->getMetadata()->toArray($defaultLocale);
        $appEntity = $this->updateApp($manifest$metadata$app['id']$app['roleId']$defaultLocale$context, false);

        $event = new AppUpdatedEvent($appEntity$manifest$context);
        $this->eventDispatcher->dispatch($event);
        $this->scriptExecutor->execute(new AppUpdatedHook($event));
    }

    /** * @param array{id: string} $app */
    public function delete(string $appName, array $app, Context $context, bool $keepUserData = false): void
    {
        $appEntity = $this->loadApp($app['id']$context);

        
Home | Imprint | This part of the site doesn't use cookies.