class GroupByTest
Same name and namespace in other branches
- 11.x core/modules/views_ui/tests/src/Functional/GroupByTest.php \Drupal\Tests\views_ui\Functional\GroupByTest
- 10 core/modules/views_ui/tests/src/Functional/GroupByTest.php \Drupal\Tests\views_ui\Functional\GroupByTest
- 8.9.x core/modules/views_ui/tests/src/Functional/GroupByTest.php \Drupal\Tests\views_ui\Functional\GroupByTest
Tests UI of aggregate functionality..
@group views_ui
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_ui\Functional\UITestBase extends \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views_ui\Functional\GroupByTest extends \Drupal\Tests\views_ui\Functional\UITestBase
- class \Drupal\Tests\views_ui\Functional\UITestBase 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 GroupByTest
File
-
core/
modules/ views_ui/ tests/ src/ Functional/ GroupByTest.php, line 10
Namespace
Drupal\Tests\views_ui\FunctionalView source
class GroupByTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_views_groupby_save',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests whether basic saving works.
*
* @todo This should check the change of the settings as well.
*/
public function testGroupBySave() {
$this->drupalGet('admin/structure/views/view/test_views_groupby_save/edit');
$edit_groupby_url = 'admin/structure/views/nojs/handler-group/test_views_groupby_save/default/field/id';
$this->assertSession()
->linkByHrefNotExists($edit_groupby_url, 0, 'No aggregation link found.');
// Enable aggregation on the view.
$edit = [
'group_by' => TRUE,
];
$this->drupalGet('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by');
$this->submitForm($edit, 'Apply');
$this->assertSession()
->linkByHrefExists($edit_groupby_url, 0, 'Aggregation link found.');
// Change the groupby type in the UI.
$this->drupalGet($edit_groupby_url);
$this->submitForm([
'options[group_type]' => 'count',
], 'Apply');
$this->assertSession()
->linkExists('COUNT(Views test: ID)', 0, 'The count setting is displayed in the UI');
$this->submitForm([], 'Save');
$view = $this->container
->get('entity_type.manager')
->getStorage('view')
->load('test_views_groupby_save');
$display = $view->getDisplay('default');
$this->assertTrue($display['display_options']['group_by'], 'The groupby setting was saved on the view.');
$this->assertEquals('count', $display['display_options']['fields']['id']['group_type'], 'Count groupby_type was saved on the view.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.