ScalarValuesStorer example


class ScalarFlowStorerTest extends TestCase
{
    public function testCallOldFirst(): void
    {
        $event = new BcEvent();

        $stored = [];
        $stored = (new ScalarValuesStorer())->store($event$stored);

        // check old value is stored correctly         if (!Feature::isActive('v6.6.0.0')) {
            $stored = (new ShopNameStorer())->store($event$stored);
            static::assertArrayHasKey('shopName', $stored);
            static::assertEquals('my-shop-name', $stored['shopName']);
        }

        // check new value are stored correctly         static::assertArrayHasKey(ScalarValuesAware::STORE_VALUES, $stored);
        static::assertArrayHasKey('shopName', $stored[ScalarValuesAware::STORE_VALUES]);
        

class CustomerDoubleOptInRegistrationEventTest extends TestCase
{
    public function testRestoreScalarValuesCorrectly(): void
    {
        $event = new CustomerDoubleOptInRegistrationEvent(
            new CustomerEntity(),
            $this->createMock(SalesChannelContext::class),
            'my-confirm-url'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('confirmUrl', $flow->data());
        static::assertEquals('my-confirm-url', $flow->data()['confirmUrl']);
    }
}

class CustomerBeforeLoginEventTest extends TestCase
{
    public function testRestoreScalarValuesCorrectly(): void
    {
        $event = new CustomerBeforeLoginEvent(
            $this->createMock(SalesChannelContext::class),
            'my-email'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('email', $flow->data());
        static::assertEquals('my-email', $flow->data()['email']);
    }
}
static::assertCount(1, $eventDataCollection->toArray());
        static::assertEquals(
            (new EventDataCollection())->add('mediaId', new ScalarValueType(ScalarValueType::TYPE_STRING)),
            $eventDataCollection
        );
    }

    public function testRestoreScalarValuesCorrectly(): void
    {
        $event = new MediaUploadedEvent('media-id', Context::createDefaultContext());

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('mediaId', $flow->data());
        static::assertEquals('media-id', $flow->data()['mediaId']);
    }

    

class MailErrorEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new MailErrorEvent(
            Context::createDefaultContext()
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('name', $flow->data());
        static::assertEquals('mail.sent.error', $flow->getData('name'));
    }

    
public function testScalarValuesCorrectly(): void
    {
        $event = new ReviewFormEvent(
            Context::createDefaultContext(),
            'sales-channel-id',
            new MailRecipientStruct(['foo', 'bar']),
            new DataBag(['foo' => 'bar', 'bar' => 'baz']),
            'product-id',
            'customer-id'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('reviewFormData', $flow->data());
        static::assertEquals(['foo' => 'bar', 'bar' => 'baz']$flow->data()['reviewFormData']);
    }
}

class DoubleOptInGuestOrderEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new DoubleOptInGuestOrderEvent(
            new CustomerEntity(),
            $this->createMock(SalesChannelContext::class),
            'my-confirm-url'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('confirmUrl', $flow->data());
        static::assertEquals('my-confirm-url', $flow->data()['confirmUrl']);
    }
}
class ContactFormEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new ContactFormEvent(
            Context::createDefaultContext(),
            'sales-channel-id',
            new MailRecipientStruct(['foo', 'bar']),
            new DataBag(['foo' => 'bar', 'bar' => 'baz'])
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('contactFormData', $flow->data());
        static::assertEquals(['foo' => 'bar', 'bar' => 'baz']$flow->data()['contactFormData']);
    }
}

class MailBeforeSentEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new MailBeforeSentEvent(
            ['foo' => 'bar'],
            new Email(),
            Context::createDefaultContext()
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('data', $flow->data());
        static::assertEquals(['foo' => 'bar']$flow->data()['data']);
    }

    

class ProductExportLoggingEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new ProductExportLoggingEvent(
            Context::createDefaultContext(),
            'custom-name',
            null
        );

        $storer = new ScalarValuesStorer();
        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('name', $flow->data());
        static::assertEquals('custom-name', $flow->data()['name']);
    }
}
#[Package('system-settings')] class UserRecoveryRequestEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new UserRecoveryRequestEvent(
            new UserRecoveryEntity(),
            'my-reset-url',
            Context::createDefaultContext(),
        );

        $storer = new ScalarValuesStorer();
        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('resetUrl', $flow->data());
        static::assertEquals('my-reset-url', $flow->data()['resetUrl']);
    }
}
$salesChannel->setTranslated(['name' => 'my-shop-name']);

        $context = $this->createMock(SalesChannelContext::class);
        $context->expects(static::any())->method('getSalesChannel')->willReturn($salesChannel);

        $event = new CustomerAccountRecoverRequestEvent(
            $context,
            new CustomerRecoveryEntity(),
            'my-reset-url'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('resetUrl', $flow->data());
        static::assertArrayHasKey('shopName', $flow->data());
        static::assertEquals('my-reset-url', $flow->data()['resetUrl']);
        static::assertEquals('my-shop-name', $flow->data()['shopName']);
    }
class NewsletterRegisterEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new NewsletterRegisterEvent(
            Context::createDefaultContext(),
            new NewsletterRecipientEntity(),
            'my-url',
            'my-sales-channel-id'
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('url', $flow->data());
        static::assertEquals('my-url', $flow->data()['url']);
    }
}

class MailBeforeValidateEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new MailBeforeValidateEvent(
            ['foo' => 'bar'],
            Context::createDefaultContext(),
            ['template' => 'data'],
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('data', $flow->data());
        static::assertArrayHasKey('templateData', $flow->data());
        static::assertEquals(['foo' => 'bar']$flow->data()['data']);
        static::assertEquals(['template' => 'data']$flow->data()['templateData']);
    }
class MailSentEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new MailSentEvent(
            'my-subject',
            ['foo' => 'bar'],
            ['mixed' => 'content'],
            Context::createDefaultContext()
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        $storer->restore($flow);

        static::assertArrayHasKey('subject', $flow->data());
        static::assertArrayHasKey('contents', $flow->data());
        static::assertArrayHasKey('recipients', $flow->data());

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