function StyleTableTest::testNumericFieldVisible

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
  2. 10 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testNumericFieldVisible()
  3. 11.x 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 111

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');
    $this->assertSession()
        ->elementExists('xpath', '//tbody/tr/td[contains(., "Baby")]');
    $this->assertSession()
        ->elementExists('xpath', '//tbody/tr/td[text()=0]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.