You are here

public function ViewsAggregatorStyleTableTest::testNumericFieldVisible in Views Aggregator Plus 8

Test that a number with the value of "0" is displayed in the table.

File

tests/src/Functional/Plugin/ViewsAggregatorStyleTableTest.php, line 128

Class

ViewsAggregatorStyleTableTest
Tests the views aggregator result table style plugin.

Namespace

Drupal\Tests\views_aggregator\Functional\Plugin

Code

public function testNumericFieldVisible() {

  // Adds a new datapoint in the views_test_data table to have a person with
  // an age of zero.
  $data_set = $this
    ->dataSet();
  $connection = \Drupal::database();
  $query = $connection
    ->insert('views_test_data')
    ->fields(array_keys($data_set[0]));
  $query
    ->values([
    'name' => 'James McCartney',
    'age' => 0,
    'job' => 'Baby',
    'created' => gmmktime(6, 30, 10, 1, 1, 2000),
    'status' => 1,
  ]);
  $query
    ->execute();
  $this
    ->drupalGet('va-test-style-table');
  $result = $this
    ->xpath('//tbody/tr/td[contains(., "Baby")]');
  $this
    ->assertTrue(count($result) > 0, 'Ensure that the baby is found.');
  $result = $this
    ->xpath('//tbody/tr/td[text()=0]');
  $this
    ->assertTrue(count($result) > 0, 'Ensure that the baby\'s age is shown');
}