FirstRunWizardStartedEvent example

private readonly EventDispatcherInterface $eventDispatcher,
        private readonly FirstRunWizardClient $frwClient,
        private readonly EntityRepository $userConfigRepository,
        private readonly TrackingEventClient $trackingEventClient
    ) {
    }

    public function startFrw(Context $context): void
    {
        $this->trackingEventClient->fireTrackingEvent(self::TRACKING_EVENT_FRW_STARTED);

        $this->eventDispatcher->dispatch(new FirstRunWizardStartedEvent($this->getFrwState()$context));
    }

    public function frwLogin(string $shopwareId, string $password, Context $context): void
    {
        $accessTokenResponse = $this->frwClient->frwLogin($shopwareId$password$context);
        $accessToken = $this->createAccessTokenStruct($accessTokenResponse$accessTokenResponse['firstRunWizardUserToken']);

        $this->updateFrwUserToken($context$accessToken);
    }

    public function upgradeAccessToken(Context $context): void
    {
class FirstRunWizardServiceTest extends TestCase
{
    private Context $context;

    protected function setUp(): void
    {
        $this->context = new Context(new AdminApiSource(Uuid::randomHex()));
    }

    public function testTracksAndDispatchesEventWhenFrwIsStarted(): void
    {
        $firstRunWizardStartedEvent = new FirstRunWizardStartedEvent(FrwState::openState()$this->context);

        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
        $eventDispatcher->expects(static::once())
            ->method('dispatch')
            ->with($firstRunWizardStartedEvent);

        $trackingEventClient = $this->createMock(TrackingEventClient::class);
        $trackingEventClient->expects(static::once())
            ->method('fireTrackingEvent')
            ->with('First Run Wizard started');

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