X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews_ui%2Fsrc%2FTests%2FGroupByTest.php;fp=web%2Fcore%2Fmodules%2Fviews_ui%2Fsrc%2FTests%2FGroupByTest.php;h=4b564c518688efaee19db53567015547d3a6ac02;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/views_ui/src/Tests/GroupByTest.php b/web/core/modules/views_ui/src/Tests/GroupByTest.php new file mode 100644 index 000000000..4b564c518 --- /dev/null +++ b/web/core/modules/views_ui/src/Tests/GroupByTest.php @@ -0,0 +1,50 @@ +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->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.'); + + // Enable aggregation on the view. + $edit = [ + 'group_by' => TRUE, + ]; + $this->drupalPostForm('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Apply')); + + $this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.'); + + // Change the groupby type in the UI. + $this->drupalPostForm($edit_groupby_url, ['options[group_type]' => 'count'], t('Apply')); + $this->assertLink('COUNT(Views test: ID)', 0, 'The count setting is displayed in the UI'); + + $this->drupalPostForm(NULL, [], t('Save')); + + $view = $this->container->get('entity.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->assertEqual($display['display_options']['fields']['id']['group_type'], 'count', 'Count groupby_type was saved on the view.'); + } + +}