prepareTestData example


    use AdminApiTestBehaviour;
    use AdminFunctionalTestBehaviour;
    use IntegrationTestBehaviour;

    protected function setup(): void
    {
        $roles = ['product:read', 'product_manufacturer:read', 'user:read'];

        $this->authorizeBrowser($this->getBrowser()[UserVerifiedScope::IDENTIFIER]$roles);

        $this->prepareTestData();
    }

    /** * @dataProvider searchDataProvider */
    public function testSearch(array $data, bool $hasResponse, array $expectedEntities, array $expectedErrors = []): void
    {
        $this->getBrowser()->request('POST', '/api/_admin/search', [][][]json_encode($data, \JSON_THROW_ON_ERROR) ?: null);
        $response = $this->getBrowser()->getResponse();
        $content = json_decode($response->getContent() ?: '', true, 512, \JSON_THROW_ON_ERROR);

        
private FilterTagIdsService $filterTagIdsService;

    protected function setup(): void
    {
        $this->ids = new IdsCollection();
        $this->filterTagIdsService = $this->getContainer()->get(FilterTagIdsService::class);
    }

    public function testFilterIdsWithDuplicateFilter(): void
    {
        $this->prepareTestData();

        $request = new Request();
        $request->request->set('duplicateFilter', true);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('landingPages.id', null));
        $criteria->addSorting(new FieldSorting('categories.name', FieldSorting::ASCENDING));

        $filteredTagIdsStruct = $this->filterTagIdsService->filterIds(
            $request,
            $criteria,
            
class AdminProductStreamControllerTest extends TestCase
{
    use AdminApiTestBehaviour;
    use AdminFunctionalTestBehaviour;
    use IntegrationTestBehaviour;

    private IdsCollection $ids;

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

    public function testPreview(): void
    {
        $data = [
            'page' => 1,
            'limit' => 25,
            'filter' => [
                [
                    'field' => null,
                    'type' => 'multi',
                    
$this->validator->validate(null, new Collection(['fields' => [
            'foo' => new Range(['min' => 4]),
        ]]));

        $this->assertNoViolation();
    }

    public function testFieldsAsDefaultOption()
    {
        $constraint = new Range(['min' => 4]);

        $data = $this->prepareTestData(['foo' => 'foobar']);

        $this->expectValidateValueAt(0, '[foo]', $data['foo'][$constraint]);

        $this->validator->validate($datanew Collection([
            'foo' => $constraint,
        ]));

        $this->assertNoViolation();
    }

    public function testThrowsExceptionIfNotTraversable()
    {
Home | Imprint | This part of the site doesn't use cookies.