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