store example

protected function setUp(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);
        $this->storer = new ShopNameStorer();
    }

    public function testStoreWithAware(): void
    {
        $event = $this->createMock(CustomerAccountRecoverRequestEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(ShopNameAware::SHOP_NAME, $stored);
    }

    public function testStoreWithNotAware(): void
    {
        $event = $this->createMock(TestFlowBusinessEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(ShopNameAware::SHOP_NAME, $stored);
    }

    
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']);
    }
}
protected function setUp(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $this->storer = new ContactFormDataStorer();
    }

    public function testStoreAware(): void
    {
        $event = new ContactFormEvent(Context::createDefaultContext(), '', new MailRecipientStruct([])new DataBag());
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(ContactFormDataAware::CONTACT_FORM_DATA, $stored);
    }

    public function testStoreNotAware(): void
    {
        $event = $this->createMock(TestFlowBusinessEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(ContactFormDataAware::CONTACT_FORM_DATA, $stored);
    }

    
// Test a cache hit.     $filename = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'llama-42.txt';
    $realpath = realpath($filename);
    $cid = 'prefix:test:' . $realpath;
    $data = [
      'mtime' => filemtime($realpath),
      'filepath' => $realpath,
      'data' => 42,
    ];

    $this->staticFileCache->store($cid$data);

    $result = $this->fileCache->get($filename);
    $this->assertEquals(42, $result);

    // Cleanup static caches.     $this->fileCache->delete($filename);
  }

  /** * @covers ::getMultiple */
  
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']);
    }
}

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

    
protected function setUp(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);
        $this->storer = new ReviewFormDataStorer();
    }

    public function testStoreAware(): void
    {
        $event = new ReviewFormEvent(Context::createDefaultContext(), '', new MailRecipientStruct([])new DataBag(), '', '');
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(ReviewFormDataAware::REVIEW_FORM_DATA, $stored);
    }

    public function testStoreNotAware(): void
    {
        $event = $this->createMock(TestFlowBusinessEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(ReviewFormDataAware::REVIEW_FORM_DATA, $stored);
    }

    
protected function setUp(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);
        $this->storer = new MediaUploadedStorer();
    }

    public function testStoreWithAware(): void
    {
        $event = $this->createMock(MediaUploadedEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(MediaUploadedAware::MEDIA_ID, $stored);
    }

    public function testStoreWithNotAware(): void
    {
        $event = $this->createMock(TestFlowBusinessEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(MediaUploadedAware::MEDIA_ID, $stored);
    }

    

    protected function store(Request $request, Response $response)
    {
        // Not cache sites with nocache header         if ($this->containsNoCacheTag($request$response)) {
            return;
        }

        parent::store($request$response);
    }

    /** * Checks whether or not the response header contains * a no-cache header that matches one in the request cookie * * @return bool */
    protected function containsNoCacheTag(Request $request, Response $response)
    {
        // Not cache sites with nocache header
if ($response->headers->has($name)) {
                    $entry->headers->set($name$response->headers->get($name));
                }
            }

            $response = $entry;
        } else {
            $this->record($request, 'invalid');
        }

        if ($response->isCacheable()) {
            $this->store($request$response);
        }

        return $response;
    }

    /** * Unconditionally fetches a fresh response from the backend and * stores it in the cache if is cacheable. * * @param bool $catch Whether to process exceptions */
    

class RedisInvalidatorStorageTest extends TestCase
{
    public function testStorage(): void
    {
        $storage = new RedisInvalidatorStorage(new RedisStub());

        static::assertSame($storage->loadAndDelete()[]);

        $storage->store(['foo', 'bar']);

        static::assertSame(['bar', 'foo']$storage->loadAndDelete());
        static::assertSame([]$storage->loadAndDelete());
    }
}
protected function setUp(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);
        $this->storer = new TemplateDataStorer();
    }

    public function testStoreWithAware(): void
    {
        $event = $this->createMock(MailBeforeValidateEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(TemplateDataAware::TEMPLATE_DATA, $stored);
    }

    public function testStoreWithNotAware(): void
    {
        $event = $this->createMock(TestFlowBusinessEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(TemplateDataAware::TEMPLATE_DATA, $stored);
    }

    
protected function setUp(): void
    {
        $this->repository = $this->createMock(EntityRepository::class);
        $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
        $this->storer = new UserStorer($this->repository, $this->dispatcher);
    }

    public function testStoreWithAware(): void
    {
        $event = $this->createMock(UserRecoveryRequestEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(UserAware::USER_RECOVERY_ID, $stored);
    }

    public function testStore(): void
    {
        $event = $this->createMock(CustomerRegisterEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(UserAware::USER_RECOVERY_ID, $stored);
    }

    
class CacheInvalidatorStorageTest extends TestCase
{
    /** * @DisabledFeatures("v6.6.0.0") */
    public function testStorage(): void
    {
        $storage = new CacheInvalidatorStorage(new ArrayAdapter());

        static::assertSame($storage->loadAndDelete()[]);

        $storage->store(['foo', 'bar']);

        static::assertSame(['foo', 'bar']$storage->loadAndDelete());
        static::assertSame([]$storage->loadAndDelete());
    }
}
protected function setUp(): void
    {
        $this->repository = $this->createMock(EntityRepository::class);
        $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
        $this->storer = new NewsletterRecipientStorer($this->repository, $this->dispatcher);
    }

    public function testStoreWithAware(): void
    {
        $event = $this->createMock(NewsletterConfirmEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayHasKey(NewsletterRecipientAware::NEWSLETTER_RECIPIENT_ID, $stored);
    }

    public function testStoreWithNotAware(): void
    {
        $event = $this->createMock(CustomerRegisterEvent::class);
        $stored = [];
        $stored = $this->storer->store($event$stored);
        static::assertArrayNotHasKey(NewsletterRecipientAware::NEWSLETTER_RECIPIENT_ID, $stored);
    }

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