diff --git a/core/modules/views/src/Tests/Plugin/StyleTableTest.php b/core/modules/views/src/Tests/Plugin/StyleTableTest.php index 9a3fbd1..341b388 100644 --- a/core/modules/views/src/Tests/Plugin/StyleTableTest.php +++ b/core/modules/views/src/Tests/Plugin/StyleTableTest.php @@ -83,17 +83,13 @@ public function testAccessibilitySettings() { public function testEmptyContent() { $this->drupalGet('test-table'); - // The 0 age is in the row (counting headers), first column. + // The 0 age is in the last row, first column. $result = $this->xpath('//table/tbody/tr[last()]/td[1]'); - if ($this->assertFalse(empty($result), 'Found a zero result field.')) { - $this->assertIdentical('0', trim((string) $result[0]), 'A zero value field was displayed correctly.'); - } + $this->assertIdentical('0', trim((string) $result[0]), 'A zero value field was displayed correctly.'); // Sanity check, George should be 27. $result = $this->xpath('//table/tbody/tr[last() - 1]/td[1]'); - if ($this->assertFalse(empty($result), 'Found a non-zero result field.')) { - $this->assertIdentical('27', trim((string) $result[0]), 'A non-zero value field was displayed correctly.'); - } + $this->assertIdentical('27', trim((string) $result[0]), 'A non-zero value field was displayed correctly.'); // Update view to consider 0 as empty. $view = entity_load('view', 'test_table'); @@ -104,16 +100,12 @@ public function testEmptyContent() { $this->drupalGet('test-table'); // The 0 age should now display an empty string. - $result = $this->xpath('//tr[6]/td[1]'); - if ($this->assertFalse(empty($result), 'Found a zero result field.')) { - $this->assertIdentical('', trim((string) $result[0]), 'A zero value field was displayed correctly.'); - } + $result = $this->xpath('//table/tbody/tr[last()]/td[1]'); + $this->assertIdentical('', trim((string) $result[0]), 'A zero value field was displayed correctly.'); // Sanity check, George should be 27. - $result = $this->xpath('//tr[5]/td[1]'); - if ($this->assertFalse(empty($result), 'Found a non-zero result field.')) { - $this->assertIdentical('27', trim((string) $result[0]), 'A non-zero value field was displayed correctly.'); - } + $result = $this->xpath('//table/tbody/tr[last() - 1]/td[1]'); + $this->assertIdentical('27', trim((string) $result[0]), 'A non-zero value field was displayed correctly.'); } /**