CacheInvalidationSubscriber example

$cacheInvalidator = $this->createMock(CacheInvalidator::class);
        $cacheInvalidator->expects(static::once())
            ->method('invalidate')
            ->with(
                [
                    'context-factory-' . $salesChannelId,
                    'base-context-factory-' . $salesChannelId,
                ],
                false
            );

        $subscriber = new CacheInvalidationSubscriber(
            $cacheInvalidator,
            $this->createMock(Connection::class),
            false,
            false
        );

        $subscriber->invalidateContext(new EntityWrittenContainerEvent(
            Context::createDefaultContext(),
            new NestedEventCollection([
                new EntityWrittenEvent(
                    SalesChannelDefinition::ENTITY_NAME,
                    [
private IdsCollection $ids;

    private MockObject $cacheInvalidatorMock;

    private CacheInvalidationSubscriber $cacheInvalidationSubscriber;

    protected function setUp(): void
    {
        $this->ids = new IdsCollection();

        $this->cacheInvalidatorMock = $this->createMock(CacheInvalidator::class);
        $this->cacheInvalidationSubscriber = new CacheInvalidationSubscriber(
            $this->cacheInvalidatorMock,
            $this->getContainer()->get(Connection::class),
            false,
            false
        );
    }

    public function testItInvalidatesCacheIfPropertyGroupIsChanged(): void
    {
        $this->insertDefaultPropertyGroup();

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