You are here

public function CounterTest::testSimpleCounter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php \Drupal\Tests\views\Unit\Plugin\field\CounterTest::testSimpleCounter()

Tests a simple counter field.

@dataProvider providerRowIndexes

File

core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php, line 118
Contains \Drupal\Tests\views\Unit\Plugin\field\CounterTest.

Class

CounterTest
@coversDefaultClass \Drupal\views\Plugin\views\field\Counter @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

public function testSimpleCounter($i) {
  $counter_handler = new Counter(array(), 'counter', $this->definition);
  $options = array();
  $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');
}