openState example

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');

        
$completedAt = $this->configService->getString('core.frw.completedAt');
        if ($completedAt !== '') {
            return FrwState::completedState(new \DateTimeImmutable($completedAt));
        }
        $failedAt = $this->configService->getString('core.frw.failedAt');
        if ($failedAt !== '') {
            $failureCount = $this->configService->getInt('core.frw.failureCount');

            return FrwState::failedState(new \DateTimeImmutable($failedAt)$failureCount);
        }

        return FrwState::openState();
    }

    private function updateFrwUserToken(Context $context, AccessTokenStruct $accessToken): void
    {
        /** @var AdminApiSource $contextSource */
        $contextSource = $context->getSource();
        $userId = $contextSource->getUserId();

        $frwUserToken = $accessToken->getShopUserToken()->getToken();
        $id = $this->getFrwUserTokenConfigId($context);

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