skipTestIfInActive example

public function testGetTokenFromResponseBody(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $token = 'sw-token-value';
        $response = new ContextTokenResponse($token);
        static::assertSame($token$response->getToken());
    }

    public function testGetTokenFromHeader(): void
    {
        Feature::skipTestIfInActive('v6.6.0.0', $this);

        $token = 'sw-token-value';
        $response = new ContextTokenResponse($token);
        static::assertSame($token$response->getToken());

        // It should be stored in a header instead         static::assertSame($token$response->headers->get(PlatformRequest::HEADER_CONTEXT_TOKEN));
    }
}
'ngram' => [
                'type' => 'text',
                'analyzer' => 'sw_ngram_analyzer',
            ],
        ],
    ];

    private readonly IdsCollection $ids;

    protected function setUp(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $this->ids = new IdsCollection();
    }

    public function testMapping(): void
    {
        $connection = $this->createMock(Connection::class);
        $connection->expects(static::exactly(2))->method('fetchAllKeyValue')->willReturn([
            'lang_en' => 'en-GB',
            'lang_de' => 'de-DE',
        ]);

        
private AbstractSalesChannelContextFactory $contextFactory;

    private SalesChannelContext $context;

    private EntityRepository $orderLineItemRepository;

    private EntityRepository $orderRepository;

    protected function setUp(): void
    {
        Feature::skipTestIfInActive('STOCK_HANDLING', $this);

        parent::setUp();
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->orderLineItemRepository = $this->getContainer()->get('order_line_item.repository');
        $this->cartService = $this->getContainer()->get(CartService::class);
        $this->contextFactory = $this->getContainer()->get(SalesChannelContextFactory::class);
        $this->lineItemRepository = $this->getContainer()->get('order_line_item.repository');
        $this->orderRepository = $this->getContainer()->get('order.repository');
        $this->addCountriesToSalesChannel();

        $this->context = $this->contextFactory->create(
            
static::assertFalse(
            $helper->allowSearch(new ProductDefinition(), Context::createDefaultContext()$criteria)
        );
    }

    /** * @dataProvider enableMultilingualIndexCases */
    public function testEnableMultilingualIndex(?int $flag, bool $expected): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $registry = $this->createMock(ElasticsearchRegistry::class);
        $registry->method('has')->willReturnMap([
            ['product', true],
            ['category', false],
        ]);

        $storage = $this->createMock(AbstractKeyValueStorage::class);
        $storage->expects(static::once())->method('get')->willReturn($flag);

        $helper = new ElasticsearchHelper(
            

        ]$esAgg->toArray());
    }

    /** * @dataProvider parseFilterDataProvider * * @param array<mixed> $expectedEsFilter */
    public function testParseFilter(Filter $filter, array $expectedEsFilter): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $definition = $this->getDefinition();

        $storage = $this->createMock(AbstractKeyValueStorage::class);
        $storage->method('get')->willReturn(true);

        $parser = new CriteriaParser(
            new EntityDefinitionQueryHelper(),
            $this->createMock(CustomFieldService::class),
            $storage
        );

        

class Migration1673964565MigrateToReferencedColumnsTest extends TestCase
{
    private Connection $connection;

    private Migration1673964565MigrateToReferencedColumns $migration;

    protected function setUp(): void
    {
        Feature::skipTestIfInActive('v6.6.0.0', $this);

        $this->migration = new Migration1673964565MigrateToReferencedColumns();
        $this->connection = KernelLifecycleManager::getConnection();
    }

    public function testGetCreationTimestamp(): void
    {
        static::assertEquals('1673964565', $this->migration->getCreationTimestamp());
    }

    public function testUpdate(): void
    {
'language.written' => 'onLanguageWritten',
            ], LanguageSubscriber::getSubscribedEvents());

            return;
        }

        static::assertSame(['sales_channel_language.written' => 'onSalesChannelWritten'], LanguageSubscriber::getSubscribedEvents());
    }

    public function testOnLanguageWrittenWithoutEsEnabled(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $esHelper = $this->createMock(ElasticsearchHelper::class);
        $esHelper->expects(static::once())->method('allowIndexing')->willReturn(false);

        $subscriber = new LanguageSubscriber(
            $esHelper,
            $this->createMock(ElasticsearchRegistry::class),
            $this->createMock(Client::class),
            $this->createMock(ProductDefinition::class),
            $this->createMock(MessageBusInterface::class)
        );

        
public function testGetAppEntityFromTechnicalNameThrowsWithoutMajorFlag(): void
    {
        Feature::skipTestIfActive('V6_6_0_0', $this);

        static::expectException(ExtensionNotFoundException::class);
        $this->extensionDataProvider->getAppEntityFromTechnicalName(Uuid::randomHex()$this->context);
    }

    public function testGetAppEntityFromTechnicalNameThrowsWithMajorFlag(): void
    {
        Feature::skipTestIfInActive('V6_6_0_0', $this);

        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage('Use StoreException::extensionNotFoundFromTechnicalName instead.');
        $this->extensionDataProvider->getAppEntityFromTechnicalName(Uuid::randomHex()$this->context);
    }

    public function testGetAppEntityFromIdThrowsWithoutMajorFlag(): void
    {
        Feature::skipTestIfActive('V6_6_0_0', $this);

        static::expectException(ExtensionNotFoundException::class);
        
private MockObject&IndexCreator $indexCreator;

    private MockObject&IteratorFactory $iteratorFactory;

    private Client&MockObject $client;

    private IndicesNamespace&MockObject $indices;

    protected function setUp(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $this->connection = $this->createMock(Connection::class);
        $this->helper = $this->createMock(ElasticsearchHelper::class);
        $this->registry = new ElasticsearchRegistry([$this->createDefinition('product')]);
        $this->indexCreator = $this->createMock(IndexCreator::class);
        $this->iteratorFactory = $this->createMock(IteratorFactory::class);
        $this->client = $this->createMock(Client::class);

        $this->helper->method('allowIndexing')->willReturn(true);

        $this->indices = $this->createMock(IndicesNamespace::class);
        
$newFlowActions = $this->getAppFlowActions($appId);
        static::assertIsArray($newFlowActions);
        static::assertCount(2, $newFlowActions);
        foreach ($flowActions as $action) {
            static::assertContains($action['id'], \array_column($newFlowActions, 'id'));
        }
    }

    public function testRefreshFlowExtension(): void
    {
        Feature::skipTestIfInActive('v6.6.0.0', $this);
        $context = Context::createDefaultContext();
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/_fixtures/withFlowExtension/manifest.xml');
        $this->appLifecycle->install($manifest, true, $this->context);

        $appId = $this->getAppId();
        static::assertIsString($appId);

        $flowActions = $this->getAppFlowActions($appId);
        static::assertIsArray($flowActions);

        $flowAction = Action::createFromXmlFile(__DIR__ . '/_fixtures/withFlowExtension/Resources/flow-v2.xml');
        

class StopwordTokenFilterTest extends TestCase
{
    use IntegrationTestBehaviour;

    private Context $context;

    private Connection $connection;

    protected function setUp(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $this->context = Context::createDefaultContext();
        $this->connection = $this->getContainer()->get(Connection::class);
    }

    /** * @dataProvider cases * * @param list<string> $tokens * @param list<string> $expected */
    
foreach ($expectedProducts as $key => $expectedProduct) {
            static::assertEquals($ids->get($expectedProduct)$resultIds[$key]sprintf('Expected product %s at position %d to be there, but got %s', $expectedProduct$key$ids->getKey($resultIds[$key])));
        }
    }

    /** * @depends testIndexing */
    public function testSearchWithStopWord(IdsCollection $ids): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $this->setSearchConfiguration(false, ['name', 'description']);
        $this->setSearchScores([]);

        $criteria = new Criteria();
        $criteria->addState(Criteria::STATE_ELASTICSEARCH_AWARE);
        $criteria->setTerm('the');
        $criteria->addSorting(new FieldSorting('name', FieldSorting::ASCENDING));

        $result = $this->productRepository->searchIds($criteria, Context::createDefaultContext());

        
$response = $this->getContainer()->get(CheckoutController::class)->info($request$salesChannelContext);
        static::assertEquals(Response::HTTP_OK, $response->getStatusCode());
        static::assertStringContainsString((string) $cart->getPrice()->getTotalPrice()(string) $response->getContent());

        $traces = $this->getContainer()->get(ScriptTraces::class)->getTraces();
        static::assertArrayHasKey(CheckoutInfoWidgetLoadedHook::HOOK_NAME, $traces);
    }

    public function testCheckoutInfoWidgetSkipsCalculationAndRenderIfCartIsEmpty(): void
    {
        Feature::skipTestIfInActive('v6.5.0.0', $this);

        $contextToken = Uuid::randomHex();

        $cartService = $this->getContainer()->get(CartService::class);
        $cartService->createNew($contextToken);

        $salesChannelContext = $this->createSalesChannelContext($contextToken);
        $request = $this->createRequest($salesChannelContext);

        $response = $this->getContainer()->get(CheckoutController::class)->info($request$salesChannelContext);
        static::assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode());
        


    public function testUninstallWithInvalidNameWithoutMajorFlag(): void
    {
        Feature::skipTestIfActive('V6_6_0_0', $this);

        $this->lifecycleService->uninstall('app', 'notExisting', false, $this->context);
    }

    public function testUninstallWithInvalidNameWithMajorFlag(): void
    {
        Feature::skipTestIfInActive('V6_6_0_0', $this);

        static::expectException(\RuntimeException::class);
        static::expectExceptionMessage('Use StoreException::extensionNotFoundFromTechnicalName instead.');
        $this->lifecycleService->uninstall('app', 'notExisting', false, $this->context);
    }

    public function testInstallAppNotExistingWithoutMajorFlag(): void
    {
        Feature::skipTestIfActive('V6_6_0_0', $this);

        static::expectException(ExtensionInstallException::class);
        
Home | Imprint | This part of the site doesn't use cookies.