You are here

public function StyleTableTest::testNumericFieldVisible in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
  2. 9 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()

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

File

core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php, line 124

Class

StyleTableTest
Tests the table style views plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testNumericFieldVisible() {

  // Adds a new data point in the views_test_data table to have a person with
  // an age of zero.
  $data_set = $this
    ->dataSet();
  $query = Database::getConnection()
    ->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('test-table');
  $result = $this
    ->xpath('//tbody/tr/td[contains(., "Baby")]');
  $this
    ->assertGreaterThan(0, count($result), 'Ensure that the baby is found.');
  $result = $this
    ->xpath('//tbody/tr/td[text()=0]');
  $this
    ->assertGreaterThan(0, count($result), 'Ensure that the baby\'s age is shown');
}