diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php
index 284d35e..da2b95c 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php
@@ -15,7 +15,7 @@
*
* @see \Drupal\views\Plugin\views\style\Grid
*/
-class StyleGridTest extends PluginUnitTestBase {
+class StyleGridTest extends PluginTestBase {
/**
* Views used by this test.
@@ -29,6 +29,9 @@ class StyleGridTest extends PluginUnitTestBase {
*/
protected $alignmentsTested = array();
+ /**
+ * {@inheritdoc}
+ */
public static function getInfo() {
return array(
'name' => 'Style: Grid',
@@ -38,6 +41,14 @@ public static function getInfo() {
}
/**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->enableViewsTestModule();
+ }
+
+ /**
* Tests the grid style.
*/
public function testGrid() {
@@ -71,8 +82,10 @@ protected function assertGrid(ViewExecutable $view, $alignment, $columns) {
$this->executeView($view);
$output = $view->preview();
$output = drupal_render($output);
+ $this->drupalSetContent($output, 'internal://test-grid');
if (!in_array($alignment, $this->alignmentsTested)) {
- $this->assertTrue(strpos($output, "
") !== FALSE, ucfirst($alignment) . " grid markup displays correctly.");
+ $result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', array(':alignment' => $alignment, ':columns' => 'cols-' . $columns));
+ $this->assertTrue(count($result), ucfirst($alignment) . " grid markup detected.");
$this->alignmentsTested[] = $alignment;
}
$width = '0';
@@ -83,14 +96,12 @@ protected function assertGrid(ViewExecutable $view, $alignment, $columns) {
case 2: $width = '50'; break;
case 1: $width = '100'; break;
}
- $clearfix = '';
- if ($alignment == 'vertical') {
- $clearfix = ' clearfix';
- }
- $this->assertTrue(strpos($output, "views-col col-$columns$clearfix\" style=\"width: $width") !== FALSE, ucfirst($alignment) . " $columns column grid: automatic width calculated correctly.");
- // Test to make sure column count does not exceed style option.
- $extraColumn = $columns + 1;
- $this->assertFalse(strpos($output, "col-$extraColumn") !== FALSE, ucfirst($alignment) . " $columns column grid: no extraneous columns exist.");
+ // Ensure last column exists.
+ $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', array(':columns' => 'col-' . $columns, ':width' => 'width: ' . $width));
+ $this->assertTrue(count($result), ucfirst($alignment) . " $columns column grid: last column exists and automatic width calculated correctly.");
+ // Ensure no extra columns were generated.
+ $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', array(':columns' => 'col-' . ($columns + 1)));
+ $this->assertFalse(count($result), ucfirst($alignment) . " $columns column grid: no extraneous columns exist.");
}
}