function StyleTableTest::testNumericFieldVisible
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
- 10 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
- 11.x core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
Test 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\PluginCode
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();
$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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.