getSubscribedEvents example


#[Package('checkout')] class PaymentHandlerIdentifierSubscriberTest extends TestCase
{
    public function testGetSubscribedEvents(): void
    {
        static::assertSame(
            [
                'payment_method.loaded' => 'formatHandlerIdentifier',
                'payment_method.partial_loaded' => 'formatHandlerIdentifier',
            ],
            PaymentHandlerIdentifierSubscriber::getSubscribedEvents()
        );
    }

    public function testFormatHandlerIdentifier(): void
    {
        $paymentMethods = [
            $this->getPaymentMethod(),
            $this->getPaymentMethod(AsynchronousPaymentHandlerInterface::class),
            $this->getPaymentMethod(RefundPaymentHandlerInterface::class),
            $this->getPaymentMethod(PreparedPaymentHandlerInterface::class),
            $this->getPaymentMethod(RecurringPaymentHandlerInterface::class),
        ];
$subscriber->salesChannelLoaded(
            new SalesChannelEntityLoadedEvent(
                $this->createMock(ProductDefinition::class),
                [$entity],
                $this->createMock(SalesChannelContext::class)
            )
        );
    }

    public function testEnsurePartialsEventsConsidered(): void
    {
        $events = ProductSubscriber::getSubscribedEvents();
        static::assertArrayHasKey('product.loaded', $events);
        static::assertArrayHasKey('product.partial_loaded', $events);
        static::assertArrayHasKey('sales_channel.product.loaded', $events);
        static::assertArrayHasKey('sales_channel.product.partial_loaded', $events);
    }
}

class UnusedMediaSubscriberTest extends TestCase
{
    public function testSubscribedEvents(): void
    {
        static::assertEquals(
            [
                UnusedMediaSearchEvent::class => 'removeUsedMedia',
            ],
            UnusedMediaSubscriber::getSubscribedEvents()
        );
    }

    public function testUsedThemeMediaIdsAreRemoved(): void
    {
        $themeId1 = Uuid::randomHex();
        $themeId2 = Uuid::randomHex();

        $mediaId1 = Uuid::randomHex();
        $mediaId2 = Uuid::randomHex();
        $mediaId3 = Uuid::randomHex();
        
/** * @internal * * @covers \Shopware\Core\Installer\Subscriber\InstallerLocaleListener */
class InstallerLocaleListenerTest extends TestCase
{
    public function testGetSubscribedEvents(): void
    {
        static::assertSame(
            [RequestEvent::class],
            array_keys(InstallerLocaleListener::getSubscribedEvents())
        );
    }

    /** * @dataProvider installerLocaleProvider */
    public function testSetInstallerLocale(Request $request, string $expectedLocale): void
    {
        $listener = new InstallerLocaleListener(['de' => 'de-DE', 'en' => 'en-GB', 'nl' => 'nl-NL', 'fr' => 'fr-FR']);

        $listener->setInstallerLocale(
            
$this->cachedResolvedConfigLoaderInvalidator = new CachedResolvedConfigLoaderInvalidator($this->cacheInvalidator, true);
    }

    public function testGetSubscribedEvents(): void
    {
        static::assertEquals(
            [
                ThemeConfigChangedEvent::class => 'invalidate',
                ThemeAssignedEvent::class => 'assigned',
                ThemeConfigResetEvent::class => 'reset',
            ],
            CachedResolvedConfigLoaderInvalidator::getSubscribedEvents()
        );
    }

    public function testAssigned(): void
    {
        $themeId = Uuid::randomHex();
        $salesChannelId = Uuid::randomHex();
        $event = new ThemeAssignedEvent($themeId$salesChannelId);
        $name = 'theme-config-' . $themeId;

        $expectedInvalidatedTags = [
            
private IdsCollection $ids;

    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();
        $this->ids = new IdsCollection();
    }

    public function testGetSubscribedEvents(): void
    {
        $events = StockUpdater::getSubscribedEvents();

        static::assertArrayHasKey(CheckoutOrderPlacedEvent::class$events);
        static::assertArrayHasKey(StateMachineTransitionEvent::class$events);
        static::assertArrayHasKey(PreWriteValidationEvent::class$events);
        static::assertArrayHasKey(OrderEvents::ORDER_LINE_ITEM_WRITTEN_EVENT, $events);
        static::assertArrayHasKey(OrderEvents::ORDER_LINE_ITEM_DELETED_EVENT, $events);
    }

    public function testTriggerChangeSetWithNonLiveVersion(): void
    {
        $definition = new OrderLineItemDefinition();
        
/** * @internal * * @covers \Shopware\Core\Framework\App\Flow\Action\AppFlowActionLoadedSubscriber */
class AppFlowActionLoadedSubscriberTest extends TestCase
{
    public function testGetSubscribedEvents(): void
    {
        static::assertEquals([
            'app_flow_action.loaded' => 'unserialize',
        ], AppFlowActionLoadedSubscriber::getSubscribedEvents());
    }

    public function testUnserialize(): void
    {
        $idFlowAction = Uuid::randomHex();

        $appFlowAction = new AppFlowActionEntity();
        $appFlowAction->setId($idFlowAction);
        $iconPath = __DIR__ . '/../../Manifest/_fixtures/icon.png';

        $fileIcon = '';
        

    private ThemeNamespaceHierarchyBuilder $builder;

    protected function setUp(): void
    {
        $themeLoader = $this->createMock(SalesChannelThemeLoader::class);
        $this->builder = new ThemeNamespaceHierarchyBuilder(new TestInheritanceBuilder()$themeLoader);
    }

    public function testThemeNamespaceHierarchyBuilderSubscribesToRequestAndExceptionEvents(): void
    {
        $events = $this->builder->getSubscribedEvents();

        static::assertEquals([
            KernelEvents::REQUEST,
            KernelEvents::EXCEPTION,
            DocumentTemplateRendererParameterEvent::class,
        ]array_keys($events));
    }

    public function testThemesAreEmptyIfRequestHasNoValidAttributes(): void
    {
        $request = Request::createFromGlobals();

        

class ActiveRulesDataCollectorSubscriberTest extends TestCase
{
    public function testEvents(): void
    {
        static::assertSame(
            [
                SalesChannelContextResolvedEvent::class => 'onContextResolved',
            ],
            ActiveRulesDataCollectorSubscriber::getSubscribedEvents()
        );
    }

    public function testDataCollection(): void
    {
        $ruleId = Uuid::randomHex();

        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $context = new Context(new SystemSource()[$ruleId]);
        $salesChannelContext->method('getContext')->willReturn($context);
        $event = new SalesChannelContextResolvedEvent($salesChannelContext, Uuid::randomHex());

        
static::assertArrayHasKey('themeIconConfig', $event->getParameters());
        static::assertEquals([
            'custom-icons' => [
                'path' => 'app/storefront/src/assets/icon-pack/custom-icons',
                'namespace' => 'SwagTheme',
            ],
        ]$event->getParameters()['themeIconConfig']);
    }

    public function testSubscribedEvents(): void
    {
        static::assertCount(2, (array) StorefrontSubscriber::getSubscribedEvents()[KernelEvents::EXCEPTION]);
    }
}
use Shopware\Elasticsearch\Product\ProductUpdater;

/** * @internal * * @covers \Shopware\Elasticsearch\Product\ProductUpdater */
class ProductUpdaterTest extends TestCase
{
    public function testGetSubscribedEvents(): void
    {
        static::assertSame([ProductIndexerEvent::class => 'update'], ProductUpdater::getSubscribedEvents());
    }

    public function testUpdate(): void
    {
        $indexer = $this->createMock(ElasticsearchIndexer::class);
        $definition = $this->createMock(EntityDefinition::class);

        $indexer->expects(static::once())->method('updateIds')->with($definition['id1', 'id2']);

        $event = new ProductIndexerEvent(['id1', 'id2'], Context::createDefaultContext());

        

        $this->connection = $this->createMock(Connection::class);

        $this->salutationSubscriber = new CustomerSalutationSubscriber($this->connection);
    }

    public function testGetSubscribedEvents(): void
    {
        static::assertEquals([
            CustomerEvents::CUSTOMER_WRITTEN_EVENT => 'setDefaultSalutation',
            CustomerEvents::CUSTOMER_ADDRESS_WRITTEN_EVENT => 'setDefaultSalutation',
        ]$this->salutationSubscriber->getSubscribedEvents());
    }

    public function testSkip(): void
    {
        $writeResults = [
            new EntityWriteResult(
                'created-id',
                ['id' => Uuid::randomHex(), 'salutationId' => Uuid::randomHex()],
                'customer',
                EntityWriteResult::OPERATION_INSERT
            ),
        ];
yield preg_replace('/^ @@.*/m', '', $m);
            yield print_r($defaults, true);
        }

        if ($class->isAbstract() || $class->isInterface() || $class->isTrait()) {
            return;
        }

        if (interface_exists(EventSubscriberInterface::class, false) && $class->isSubclassOf(EventSubscriberInterface::class)) {
            yield EventSubscriberInterface::class;
            yield print_r($class->name::getSubscribedEvents(), true);
        }

        if (interface_exists(MessageSubscriberInterface::class, false) && $class->isSubclassOf(MessageSubscriberInterface::class)) {
            yield MessageSubscriberInterface::class;
            foreach ($class->name::getHandledMessages() as $key => $value) {
                yield $key.print_r($value, true);
            }
        }

        if (interface_exists(ServiceSubscriberInterface::class, false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) {
            yield ServiceSubscriberInterface::class;
            
$listener = new ErrorListener($logger);
        $listener->onConsoleTerminate($this->getConsoleTerminateEvent(new ArgvInput(['console.php', 'test:run']), 0));
    }

    public function testGetSubscribedEvents()
    {
        $this->assertSame(
            [
                'console.error' => ['onConsoleError', -128],
                'console.terminate' => ['onConsoleTerminate', -128],
            ],
            ErrorListener::getSubscribedEvents()
        );
    }

    public function testAllKindsOfInputCanBeLogged()
    {
        $logger = $this->createMock(LoggerInterface::class);
        $logger
            ->expects($this->exactly(3))
            ->method('debug')
            ->with('Command "{command}" exited with code "{code}"', ['command' => 'test:run --foo=bar', 'code' => 255])
        ;

        

    public function testSubscribeToOrderLineItemWritten(): void
    {
        $expectedEvent = CheckoutOrderPlacedEvent::class;

        // we need to have a key for the Shopware event         static::assertArrayHasKey($expectedEvent, PromotionIndividualCodeRedeemer::getSubscribedEvents());
    }
}
Home | Imprint | This part of the site doesn't use cookies.