class FieldGroupRowsWebTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Functional/Handler/FieldGroupRowsWebTest.php \Drupal\Tests\views\Functional\Handler\FieldGroupRowsWebTest
- 10 core/modules/views/tests/src/Functional/Handler/FieldGroupRowsWebTest.php \Drupal\Tests\views\Functional\Handler\FieldGroupRowsWebTest
- 8.9.x core/modules/views/tests/src/Functional/Handler/FieldGroupRowsWebTest.php \Drupal\Tests\views\Functional\Handler\FieldGroupRowsWebTest
Tests the "Display all values in the same row" setting.
@group views
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\views\Functional\Handler\FieldGroupRowsWebTest extends \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of FieldGroupRowsWebTest
File
-
core/
modules/ views/ tests/ src/ Functional/ Handler/ FieldGroupRowsWebTest.php, line 15
Namespace
Drupal\Tests\views\Functional\HandlerView source
class FieldGroupRowsWebTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_group_rows',
'test_ungroup_rows',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The page node type.
*
* @var \Drupal\node\NodeTypeInterface
*/
protected $nodeType;
/**
* The used field name in the test.
*
* @var string
*/
protected $fieldName;
/**
* The field storage.
*
* @var \Drupal\field\Entity\FieldStorageConfig
*/
protected $fieldStorage;
/**
* The field config.
*
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp($import_test_views, $modules);
// Create content type with unlimited text field.
$this->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[] = $row->getText();
}
$this->assertEquals([
'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[] = $row->getText();
}
$this->assertEquals([
'a',
'b',
'c',
], $rendered_value);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.