CustomTriggerByNameNotFoundException example

null,
                new Criteria(),
                Context::createDefaultContext(),
            ),
        ]);

        $this->triggerFlowController = new TriggerFlowController(new EventDispatcher()$this->appFlowEventRepository);
    }

    public function testTriggerWithWrongEventName(): void
    {
        $this->expectExceptionObject(new CustomTriggerByNameNotFoundException('custom.checkout.event'));

        $request = new Request();
        $request->setMethod('POST');
        $context = Context::createDefaultContext();
        $appFlowEventRepository = new StaticEntityRepository([
            new EntitySearchResult(
                'app_flow_event',
                1,
                new EntityCollection([]),
                null,
                new Criteria(),
                
'message' => \sprintf('The trigger `%s`successfully dispatched!', $eventName),
        ], Response::HTTP_OK);
    }

    private function checkAppEventIsExist(string $eventName, Context $context): void
    {
        $criteria = new Criteria();
        $criteria->setLimit(1);
        $criteria->addFilter(new EqualsFilter('name', $eventName));
        $criteria->addFilter(new EqualsFilter('app.active', 1));

        $this->appFlowEventRepository->search($criteria$context)->first() ?? throw new CustomTriggerByNameNotFoundException($eventName);
    }
}
/** * @internal * * @covers \Shopware\Core\Content\Flow\Exception\CustomTriggerByNameNotFoundException */
#[Package('business-ops')] class CustomTriggerByNameNotFoundExceptionTest extends TestCase
{
    public function testException(): void
    {
        $exception = new CustomTriggerByNameNotFoundException('event_name_test');
        static::assertEquals('The provided event name event_name_test is invalid or uninstalled and no custom trigger could be found.', $exception->getMessage());
        static::assertEquals('ADMINISTRATION__CUSTOM_TRIGGER_BY_NAME_NOT_FOUND', $exception->getErrorCode());
        static::assertEquals(Response::HTTP_NOT_FOUND, $exception->getStatusCode());
    }
}
Home | Imprint | This part of the site doesn't use cookies.