createLanguage example

/** * @dataProvider productFeatureProdiver * * @param array{type: string} $testedFeature * @param array<string, mixed> $productData * @param array{type: string, value: array{price: string}, label: string} $expectedFeature * * @group slow */
    public function testProductFeaturesContainCorrectInformation(array $testedFeature, array $productData, array $expectedFeature): void
    {
        $this->createLanguage(self::TEST_LANGUAGE_ID);

        if ($testedFeature['type'] === ProductFeatureSetDefinition::TYPE_PRODUCT_CUSTOM_FIELD) {
            $this->createCustomField([]);
        }

        $this->createProduct([...[
            'featureSet' => $this->createFeatureSet([$testedFeature]),
        ], ...$productData]);

        $cart = $this->getProductCart();
        $lineItem = $cart->get($this->ids->get('product'));

        

class TranslationTest extends TestCase
{
    use AdminFunctionalTestBehaviour;

    public function testNoOverride(): void
    {
        $langId = Uuid::randomHex();
        $this->createLanguage($langId);

        $this->assertTranslation(
            ['name' => 'not translated', 'translated' => ['name' => 'not translated']],
            [
                'translations' => [
                    Defaults::LANGUAGE_SYSTEM => ['name' => 'not translated'],
                    $langId => ['name' => 'translated'],
                ],
            ]
        );
    }

    
private function providerCheapestPriceAggregation(): iterable
    {
        yield 'With no rules' => ['min' => 60, 'max' => 190, 'rules' => []];
        yield 'With rule a' => ['min' => 60, 'max' => 220, 'rules' => ['rule-a']];
        yield 'With rule b' => ['min' => 60, 'max' => 200, 'rules' => ['rule-b']];
        yield 'With rule a+b' => ['min' => 60, 'max' => 220, 'rules' => ['rule-a', 'rule-b']];
        yield 'With rule b+a' => ['min' => 60, 'max' => 220, 'rules' => ['rule-b', 'rule-a']];
    }

    private function createData(): void
    {
        $secondLanguage = $this->createLanguage();
        $this->ids->set('language-1', $secondLanguage);
        $thirdLanguage = $this->createLanguage($secondLanguage);
        $this->ids->set('language-2', $thirdLanguage);
        $fourthLanguage = $this->createLanguage();
        $this->ids->set('language-3', $fourthLanguage);
        $this->createSalesChannel(['id' => Defaults::SALES_CHANNEL_TYPE_STOREFRONT]);

        $this->getContainer()->get(Connection::class)->executeStatement('DELETE FROM custom_field');

        $customFieldRepository = $this->getContainer()->get('custom_field_set.repository');

        

        return 1536233560;
    }

    public function update(Connection $connection): void
    {
        $hasData = $connection->executeQuery('SELECT 1 FROM `language` LIMIT 1')->fetchAssociative();
        if ($hasData) {
            return;
        }

        $this->createLanguage($connection);
        $this->createLocale($connection);

        $this->createDocumentTypes($connection);
        $this->createSalutation($connection);
        $this->createCountry($connection);
        $this->createCurrency($connection);
        $this->createCustomerGroup($connection);
        $this->createPaymentMethod($connection);
        $this->createShippingMethod($connection);
        $this->createTax($connection);
        $this->createRootCategory($connection);
        

        );

        static::assertEquals('foo', $this->getBrowser()->getRequest()->headers->get('sw-custom-header'));
        static::assertArrayNotHasKey('sw-custom-header', $this->getBrowser()->getResponse()->headers->all());
    }

    public function testDifferentLanguage(): void
    {
        $langId = Uuid::randomHex();
        $salesChannel = $this->createSalesChannel();
        $this->createLanguage($langId$salesChannel['id']);

        $this->assertTranslation(
            ['name' => 'not translated', 'translated' => ['name' => 'not translated']],
            [
                'translations' => [
                    Defaults::LANGUAGE_SYSTEM => ['name' => 'not translated'],
                    $langId => ['name' => 'translated'],
                ],
            ],
            $salesChannel['id'],
            Defaults::LANGUAGE_SYSTEM
        );

            [
                'id' => $ids->create('child'),
                'parentId' => $ids->get('parent'),
                'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => 12, 'net' => 11, 'linked' => false]],
                'stock' => 2,
                'productNumber' => Uuid::randomHex(),
                'translations' => $translations['child'],
            ],
        ];

        $this->createLanguage(self::TEST_LANGUAGE_ID);

        $this->repository->create($products, Context::createDefaultContext());

        $criteria = new Criteria($ids->getList(['parent', 'child']));

        /** @var ProductCollection $products */
        $products = $this->repository->search($criteria$context)->getEntities();

        foreach ($expected as $key => $customFields) {
            $id = $ids->get('parent');
            if ($key === 'child') {
                
$this->languageRepository = $this->getContainer()->get('language.repository');
    }

    /** * @dataProvider sortingTestDataProvider */
    public function testLanguageSorting(array $languages, ?array $expectedOrder = null): void
    {
        $request = new Request();

        foreach ($languages as &$language) {
            $language['id'] = $this->createLanguage($language['name']);
        }
        unset($language);

        $context = $this->createSalesChannelContext($this->prepareSalesChannelOverride($languages));

        $pageLanguages = $this->getPageLoader()->load($request$context)->getHeader()->getLanguages()->getElements();

        $i = 0;
        foreach ($pageLanguages as $pageLanguage) {
            static::assertSame($expectedOrder[$i]$pageLanguage->getName());
            ++$i;
        }
Home | Imprint | This part of the site doesn't use cookies.