summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-10-01 15:46:42 (GMT)
committerAlex Pott2014-10-01 15:46:42 (GMT)
commit2c11d0eaef2edc274ffb8b50c75bae11c3cd7ac5 (patch)
tree06b91378964bc0bd3083021ecfa47dfc7d44637b
parent6fa850778ad035fd0a9563c9d7b1a59341e3bd26 (diff)
Issue #2239227 by marthinal, andypost | ivanjaros: Fixed Views GroupwiseMax class calls protected properties.
-rw-r--r--core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml1
-rw-r--r--core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php23
-rw-r--r--core/modules/views/src/Tests/Plugin/CacheTest.php24
-rw-r--r--core/modules/views/tests/modules/views_test_config/test_views/views.view.test_groupwise_term_ui.yml73
-rw-r--r--core/modules/views_ui/src/Tests/UITestBase.php2
-rw-r--r--core/modules/views_ui/src/Tests/ViewEditTest.php14
6 files changed, 121 insertions, 16 deletions
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
index b205693..dd9ec74 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
@@ -13,3 +13,4 @@ field_type: text
dependencies:
entity:
- field.storage.entity_test.field_test_import
+fixed_dependencies: \ No newline at end of file
diff --git a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
index c3f99f8..636746a 100644
--- a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
+++ b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
@@ -87,6 +87,7 @@ class GroupwiseMax extends RelationshipPluginBase {
// Get the sorts that apply to our base.
$sorts = Views::viewsDataHelper()->fetchFields($this->definition['base'], 'sort');
+ $sort_options = array();
foreach ($sorts as $sort_id => $sort) {
$sort_options[$sort_id] = "$sort[group]: $sort[title]";
}
@@ -122,20 +123,14 @@ class GroupwiseMax extends RelationshipPluginBase {
// WIP: This stuff doens't work yet: namespacing issues.
// A list of suitable views to pick one as the subview.
$views = array('' => '- None -');
- $all_views = Views::getAllViews();
- foreach ($all_views as $view) {
+ foreach (Views::getAllViews() as $view) {
// Only get views that are suitable:
// - base must the base that our relationship joins towards
// - must have fields.
- if ($view->base_table == $this->definition['base'] && !empty($view->display['default']['display_options']['fields'])) {
+ if ($view->get('base_table') == $this->definition['base'] && !empty($view->getDisplay('default')['display_options']['fields'])) {
// TODO: check the field is the correct sort?
// or let users hang themselves at this stage and check later?
- if ($view->type == 'Default') {
- $views[t('Default Views')][$view->storage->id()] = $view->storage->id();
- }
- else {
- $views[t('Existing Views')][$view->storage->id()] = $view->storage->id();
- }
+ $views[$view->id()] = $view->id();
}
}
@@ -171,11 +166,12 @@ class GroupwiseMax extends RelationshipPluginBase {
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->id() . ':' . $this->view->current_display . ':' . $this->options['id'];
- \Drupal::cache('views_results')->delete($cid);
+ \Drupal::cache('data')->delete($cid);
}
/**
* Generate a subquery given the user options, as set in the options.
+ *
* These are passed in rather than picked up from the object because we
* generate the subquery when the options are saved, rather than when the view
* is run. This saves considerable time.
@@ -184,7 +180,8 @@ class GroupwiseMax extends RelationshipPluginBase {
* An array of options:
* - subquery_sort: the id of a views sort.
* - subquery_order: either ASC or DESC.
- * @return
+ *
+ * @return string
* The subquery SQL string, ready for use in the main query.
*/
protected function leftQuery($options) {
@@ -358,13 +355,13 @@ class GroupwiseMax extends RelationshipPluginBase {
else {
// Get the stored subquery SQL string.
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->id() . ':' . $this->view->current_display . ':' . $this->options['id'];
- $cache = \Drupal::cache('views_results')->get($cid);
+ $cache = \Drupal::cache('data')->get($cid);
if (isset($cache->data)) {
$def['left_query'] = $cache->data;
}
else {
$def['left_query'] = $this->leftQuery($this->options);
- \Drupal::cache('views_results')->set($cid, $def['left_query']);
+ \Drupal::cache('data')->set($cid, $def['left_query']);
}
}
diff --git a/core/modules/views/src/Tests/Plugin/CacheTest.php b/core/modules/views/src/Tests/Plugin/CacheTest.php
index c5bd57d..396c3a3 100644
--- a/core/modules/views/src/Tests/Plugin/CacheTest.php
+++ b/core/modules/views/src/Tests/Plugin/CacheTest.php
@@ -23,7 +23,14 @@ class CacheTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_cache');
+ public static $testViews = array('test_view', 'test_cache', 'test_groupwise_term_ui');
+
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = array('taxonomy');
protected function setUp() {
parent::setUp();
@@ -175,4 +182,19 @@ class CacheTest extends PluginTestBase {
$this->assertTrue(empty($output['#attached']['js']), 'The cached view does not have attached JS.');
}
+ /**
+ * Tests that Subqueries are cached as expected.
+ */
+ public function testSubqueryStringCache() {
+ // Execute the view.
+ $view = Views::getView('test_groupwise_term_ui');
+ $view->setDisplay();
+ $this->executeView($view);
+ // Request for the cache.
+ $cid = 'views_relationship_groupwise_max:test_groupwise_term_ui:default:tid_representative';
+ $cache = \Drupal::cache('data')->get($cid);
+ $this->assertEqual($cid, $cache->cid, 'Subquery String cached as expected.');
+
+ }
+
}
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_groupwise_term_ui.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_groupwise_term_ui.yml
new file mode 100644
index 0000000..075d87a
--- /dev/null
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_groupwise_term_ui.yml
@@ -0,0 +1,73 @@
+base_field: tid
+base_table: taxonomy_term_data
+core: 8.0-dev
+description: ''
+status: true
+display:
+ default:
+ display_options:
+ access:
+ type: perm
+ cache:
+ type: none
+ exposed_form:
+ type: basic
+ fields:
+ name:
+ field: name
+ id: name
+ table: taxonomy_term_field_data
+ plugin_id: taxonomy
+ provider: taxonomy
+ nid:
+ field: nid
+ id: nid
+ relationship: tid_representative
+ table: node
+ plugin_id: node
+ provider: node
+ pager:
+ options:
+ items_per_page: 10
+ type: full
+ query:
+ type: views_query
+ relationships:
+ tid_representative:
+ admin_label: ''
+ field: tid_representative
+ group_type: group
+ id: tid_representative
+ label: 'Representative node'
+ relationship: none
+ required: false
+ subquery_namespace: ''
+ subquery_order: DESC
+ subquery_regenerate: false
+ subquery_sort: node.nid
+ subquery_view: ''
+ table: taxonomy_term_data
+ plugin_id: groupwise_max
+ provider: views
+ row:
+ type: fields
+ sorts:
+ tid:
+ field: tid
+ id: tid
+ order: DESC
+ table: taxonomy_term_data
+ plugin_id: standard
+ provider: views
+ style:
+ type: default
+ title: test_groupwise
+ display_plugin: default
+ display_title: Master
+ id: default
+ position: 0
+label: test_groupwise
+langcode: und
+module: views
+id: test_groupwise_term_ui
+tag: default
diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php
index 5d32952..f8cef54 100644
--- a/core/modules/views_ui/src/Tests/UITestBase.php
+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -33,7 +33,7 @@ abstract class UITestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'views_ui', 'block');
+ public static $modules = array('node', 'views_ui', 'block', 'taxonomy');
protected function setUp() {
parent::setUp();
diff --git a/core/modules/views_ui/src/Tests/ViewEditTest.php b/core/modules/views_ui/src/Tests/ViewEditTest.php
index 62036f1..d9024dd 100644
--- a/core/modules/views_ui/src/Tests/ViewEditTest.php
+++ b/core/modules/views_ui/src/Tests/ViewEditTest.php
@@ -23,7 +23,7 @@ class ViewEditTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_display');
+ public static $testViews = array('test_view', 'test_display', 'test_groupwise_term_ui');
/**
* Tests the delete link on a views UI.
@@ -153,4 +153,16 @@ class ViewEditTest extends UITestBase {
}
}
+ /**
+ * Tests Representative Node for a Taxonomy Term.
+ */
+ public function testRelationRepresentativeNode() {
+ // Populate and submit the form.
+ $edit["name[taxonomy_term_data.tid_representative]"] = TRUE;
+ $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_groupwise_term_ui/default/relationship', $edit, 'Add and configure relationships');
+ // Apply changes.
+ $edit = array();
+ $this->drupalPostForm('admin/structure/views/nojs/handler/test_groupwise_term_ui/default/relationship/tid_representative', $edit, 'Apply');
+ }
+
}