getTestRepository example

'customTranslated' => [
                        'root' => 'test',
                    ],
                ],
                'de-DE' => [
                    'customTranslated' => null,
                ],
            ],
        ];

        $chain = [$this->getDeDeLanguageId(), Defaults::LANGUAGE_SYSTEM];
        $repo = $this->getTestRepository();

        $context = Context::createDefaultContext();
        $repo->create([$entity]$context);

        $context = new Context(new SystemSource()[], Defaults::CURRENCY, $chain);

        $result = $repo->search(new Criteria([$id])$context)->first();
        static::assertInstanceOf(Entity::class$result);

        static::assertNull($result->get('customTranslated'));
        static::assertNotNull($result->getTranslation('customTranslated'));
    }

            ],
            [
                'id' => $bazId,
                'name' => 'foo\'bar',
                'custom' => [
                    'foo' => 'baz',
                ],
            ],
        ];

        $repo = $this->getTestRepository();
        $result = $repo->create($entities, Context::createDefaultContext());
        $events = $result->getEventByEntityName(CustomFieldTestDefinition::ENTITY_NAME);
        static::assertCount(2, $events->getPayloads());

        $expected = [$barId$bazId];
        static::assertEquals($expected$events->getIds());

        $actual = $repo->search(new Criteria([$barId]), Context::createDefaultContext())->first();
        static::assertEquals($barId$actual->get('id'));
        static::assertEquals($entities[0]['custom']$actual->get('custom'));

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