nodeType = $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); // Create the unlimited text field. $this->fieldName = 'field_views_testing_group_rows'; $this->fieldStorage = FieldStorageConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, ]); $this->fieldStorage->save(); // Create an instance of the text field on the content type. $this->field = FieldConfig::create([ 'field_storage' => $this->fieldStorage, 'bundle' => $this->nodeType->id(), ]); $this->field->save(); $edit = [ 'title' => $this->randomMachineName(), $this->fieldName => ['a', 'b', 'c'], ]; $this->drupalCreateNode($edit); } /** * Testing when "Display all values in the same row" is checked. */ public function testGroupRows() { $this->drupalGet('test-group-rows'); $result = $this->cssSelect('div.views-field-field-views-testing-group- div'); $rendered_value = []; foreach ($result as $row) { $rendered_value[] = (string) $row[0]; } $this->assertEqual(['a, b, c'], $rendered_value); } /** * Testing when "Display all values in the same row" is unchecked. */ public function testUngroupedRows() { $this->drupalGet('test-ungroup-rows'); $result = $this->cssSelect('div.views-field-field-views-testing-group- div'); $rendered_value = []; foreach ($result as $row) { $rendered_value[] = (string) $row[0]; } $this->assertEqual(['a', 'b', 'c'], $rendered_value); } }