Counter example

$salesChannelId,
                [SalesChannelContextService::LANGUAGE_ID => $languageId]
            );

            $parameters['context'] = $salesChannelContext;
        }

        $documentTemplateRendererParameterEvent = new DocumentTemplateRendererParameterEvent($parameters);
        $this->eventDispatcher->dispatch($documentTemplateRendererParameterEvent);
        $parameters['extensions'] = $documentTemplateRendererParameterEvent->getExtensions();

        $parameters['counter'] = new Counter();

        $view = $this->resolveView($view);

        $rendered = $this->twig->render($view$parameters);

        // If injected translator reject it         if ($context !== null && $salesChannelId !== null && $languageId !== null && $locale !== null) {
            $this->translator->resetInjection();
        }

        return $rendered;
    }
1],
      [2],
    ];
  }

  /** * Tests a simple counter field. * * @dataProvider providerRowIndexes */
  public function testSimpleCounter($i) {
    $counter_handler = new Counter([], 'counter', $this->definition);
    $options = [];
    $counter_handler->init($this->view, $this->display, $options);

    $this->view->row_index = $i;
    $expected = $i + 1;

    $counter = $counter_handler->getValue($this->testData[$i]);
    $this->assertEquals($expected$counter, 'The expected number matches with the counter number');
    $counter = $this->renderCounter($counter_handler$this->testData[$i]);
    $this->assertEquals($expected$counter, 'The expected number matches with the rendered number');
  }

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