diff -u b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php --- b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -556,6 +556,7 @@ */ protected function build_filters(&$form, &$form_state) { // Find all the fields we are allowed to filter by. + module_load_include('inc', 'views_ui', 'admin'); $fields = views_fetch_fields($this->base_table, 'filter'); $bundles = entity_get_bundles($this->entity_type); @@ -625,7 +626,7 @@ 'human_name' => $form_state['values']['human_name'], 'description' => $form_state['values']['description'], 'base_table' => $this->base_table, - 'langcode' => language_default(), + 'langcode' => language_default()->langcode, ); $view = entity_create('view', $values); @@ -822,6 +823,7 @@ // Figure out the table where $bundle_key lives. It may not be the same as // the base table for the view; the taxonomy vocabulary machine_name, for // example, is stored in taxonomy_vocabulary, not taxonomy_term_data. + module_load_include('inc', 'views_ui', 'admin'); $fields = views_fetch_fields($this->base_table, 'filter'); if (isset($fields[$this->base_table . '.' . $bundle_key])) { $table = $this->base_table; only in patch2: unchanged: --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php @@ -0,0 +1,90 @@ + 'Wizard Plugin Base', + 'description' => 'Test the wizard base plugin class', + 'group' => 'Views Wizard', + ); + } + + protected function setUp() { + parent::setUp(); + + $this->installSchema('language', 'language'); + $this->installSchema('system', 'variable'); + + $this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array()); + } + + /** + * Tests the creating of a view. + * + * @see \Drupal\views\Plugin\views\wizard\WizardPluginBase + */ + public function testCreateView() { + $form = array(); + $form_state = array(); + $form = $this->wizard->build_form($form, $form_state); + $random_id = strtolower($this->randomName()); + $random_human_name = $this->randomName(); + $random_description = $this->randomName(); + + // Add a new language and mark it as default. + $language = new Language(array( + 'langcode' => 'it', + 'name' => 'Italian', + 'default' => TRUE, + )); + language_save($language); + + $form_state['values'] = array( + 'id' => $random_id, + 'human_name' => $random_human_name, + 'description' => $random_description, + 'base_table' => 'views_test_data', + ); + + $this->wizard->validateView($form, $form_state); + $view = $this->wizard->create_view($form, $form_state); + $this->assertTrue($view instanceof ViewUI, 'The created view is a ViewUI object.'); + $this->assertEqual($view->get('id'), $random_id); + $this->assertEqual($view->get('human_name'), $random_human_name); + $this->assertEqual($view->get('description'), $random_description); + $this->assertEqual($view->get('base_table'), 'views_test_data'); + $this->assertEqual($view->get('langcode'), 'it'); + } +} +