Commit 6dc4d08c authored by catch's avatar catch

Issue #2208165 by longwave, damiankloip: Replace usage of views deprecated functions in views.

parent fd2613d2
......@@ -8,6 +8,7 @@
namespace Drupal\action\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\views\Views;
/**
* Tests the views bulk form test.
......@@ -96,7 +97,7 @@ public function testBulkForm() {
$this->assertTrue($node->isPublished(), 'An unchecked node is still published.');
// Set up to include just the sticky actions.
$view = views_get_view('test_bulk_form');
$view = Views::getView('test_bulk_form');
$display = &$view->storage->getDisplay('default');
$display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'include';
$display['display_options']['fields']['node_bulk_form']['selected_actions']['node_make_sticky_action'] = 'node_make_sticky_action';
......@@ -110,7 +111,7 @@ public function testBulkForm() {
$this->assertOption('edit-action', 'node_make_unsticky_action');
// Set up to exclude the sticky actions.
$view = views_get_view('test_bulk_form');
$view = Views::getView('test_bulk_form');
$display = &$view->storage->getDisplay('default');
$display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'exclude';
$view->save();
......@@ -125,7 +126,7 @@ public function testBulkForm() {
$this->assertEqual('With selection', (string) $result[0]);
// Setup up a different bulk form title.
$view = views_get_view('test_bulk_form');
$view = Views::getView('test_bulk_form');
$display = &$view->storage->getDisplay('default');
$display['display_options']['fields']['node_bulk_form']['action_title'] = 'Test title';
$view->save();
......
......@@ -7,6 +7,7 @@
namespace Drupal\aggregator\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewUnitTestBase;
......@@ -86,7 +87,7 @@ public function testAggregatorItemView() {
$expected[] = $values;
}
$view = views_get_view('test_aggregator_items');
$view = Views::getView('test_aggregator_items');
$this->executeView($view);
$column_map = array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\block\Tests\Views;
use Drupal\Component\Utility\String;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\Core\Template\Attribute;
......@@ -145,7 +146,7 @@ protected function testDeleteBlockDisplay() {
// Remove the block display, so both block entities from the first view
// should both disappear.
$view = views_get_view('test_view_block');
$view = Views::getView('test_view_block');
$view->initDisplay();
$view->displayHandlers->remove('block_1');
$view->storage->save();
......@@ -162,7 +163,7 @@ protected function testDeleteBlockDisplay() {
// Remove the first block display of the second view and ensure the block
// instance of the second block display still exists.
$view = views_get_view('test_view_block2');
$view = Views::getView('test_view_block2');
$view->initDisplay();
$view->displayHandlers->remove('block_1');
$view->storage->save();
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Views;
use Drupal\views\Views;
/**
* Tests the argument_comment_user_uid handler.
*/
......@@ -28,7 +30,7 @@ public static function getInfo() {
}
function testCommentUserUIDTest() {
$view = views_get_view('test_comment_user_uid');
$view = Views::getView('test_comment_user_uid');
$this->executeView($view, array($this->account->id()));
$result_set = array(
array(
......
......@@ -9,6 +9,7 @@
use Drupal\comment\CommentInterface;
use Drupal\entity\DatabaseStorageController;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
class DefaultViewRecentComments extends ViewTestBase {
......@@ -113,7 +114,7 @@ public function setUp() {
* Tests the block defined by the comments_recent view.
*/
public function testBlockDisplay() {
$view = views_get_view('comments_recent');
$view = Views::getView('comments_recent');
$view->setDisplay('block_1');
$this->executeView($view);
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Views;
use Drupal\views\Views;
/**
* Tests the filter_comment_user_uid handler.
*
......@@ -30,7 +32,7 @@ public static function getInfo() {
}
function testCommentUserUIDTest() {
$view = views_get_view('test_comment_user_uid');
$view = Views::getView('test_comment_user_uid');
$view->setDisplay();
$view->removeHandler('default', 'argument', 'uid_touch');
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\Wizard\WizardTestBase;
/**
......@@ -73,7 +74,7 @@ public function testCommentWizard() {
$this->drupalPostForm(NULL, $view, t('Save and edit'));
$this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
$view = views_get_view($view['id']);
$view = Views::getView($view['id']);
$view->initHandlers();
$row = $view->display_handler->getOption('row');
$this->assertEqual($row['type'], 'entity:comment');
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewUnitTestBase;
......@@ -87,7 +88,7 @@ public function testIntegration() {
watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']);
}
$view = views_get_view('test_dblog');
$view = Views::getView('test_dblog');
$this->executeView($view);
$view->initStyle();
......
......@@ -13,7 +13,7 @@
* The plugin that handles an EntityReference display.
*
* "entity_reference_display" is a custom property, used with
* views_get_applicable_views() to retrieve all views with a
* \Drupal\views\Views::getApplicableViews() to retrieve all views with a
* 'Entity Reference' display.
*
* @ingroup views_display_plugins
......
......@@ -7,6 +7,8 @@
namespace Drupal\field\Tests\Views;
use Drupal\views\Views;
/**
* Tests the UI of the field field handler.
*
......@@ -87,7 +89,7 @@ public function testHandlerUI() {
// Save the view and test whether the settings are saved.
$this->drupalPostForm('admin/structure/views/view/test_view_fieldapi', array(), t('Save'));
$view = views_get_view('test_view_fieldapi');
$view = Views::getView('test_view_fieldapi');
$view->initHandlers();
$this->assertEqual($view->field['field_name_0']->options['type'], 'text_trimmed');
$this->assertEqual($view->field['field_name_0']->options['settings']['trim_length'], $random_number);
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
/**
* Tests the field_field handler.
......@@ -110,7 +111,7 @@ public function testFieldRender() {
}
public function _testSimpleFieldRender() {
$view = views_get_view('test_view_fieldapi');
$view = Views::getView('test_view_fieldapi');
$this->prepareView($view);
$this->executeView($view);
......@@ -129,7 +130,7 @@ public function _testSimpleFieldRender() {
* Tests that fields with formatters runs as expected.
*/
public function _testFormatterSimpleFieldRender() {
$view = views_get_view('test_view_fieldapi');
$view = Views::getView('test_view_fieldapi');
$this->prepareView($view);
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['type'] = 'text_trimmed';
$view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['settings'] = array(
......@@ -146,7 +147,7 @@ public function _testFormatterSimpleFieldRender() {
}
public function _testMultipleFieldRender() {
$view = views_get_view('test_view_fieldapi');
$view = Views::getView('test_view_fieldapi');
$field_name = $this->fields[3]->getName();
// Test delta limit.
......
......@@ -7,6 +7,7 @@
namespace Drupal\file\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Tests\ViewTestData;
......@@ -71,7 +72,7 @@ protected function viewsData() {
* Tests file extension views field handler extension_detect_tar option.
*/
public function testFileExtensionTarOption() {
$view = views_get_view('file_extension_view');
$view = Views::getView('file_extension_view');
$view->setDisplay();
$this->executeView($view);
......
......@@ -7,6 +7,7 @@
namespace Drupal\forum\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
......@@ -74,7 +75,7 @@ public function testForumIntegration() {
}
}
$view = views_get_view('test_forum_index');
$view = Views::getView('test_forum_index');
$this->executeView($view);
$expected_result = array();
......
......@@ -7,6 +7,7 @@
namespace Drupal\history\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
/**
......@@ -71,7 +72,7 @@ public function testHandlers() {
);
// Test the history field.
$view = views_get_view('test_history');
$view = Views::getView('test_history');
$view->setDisplay('page_1');
$this->executeView($view);
$this->assertEqual(count($view->result), 2);
......@@ -81,7 +82,7 @@ public function testHandlers() {
$this->assertEqual(count($result), 1, 'Just one node is marked as new');
// Test the history filter.
$view = views_get_view('test_history');
$view = Views::getView('test_history');
$view->setDisplay('page_2');
$this->executeView($view);
$this->assertEqual(count($view->result), 1);
......
......@@ -8,6 +8,7 @@
namespace Drupal\language\Tests\Views;
use Drupal\Core\Language\Language;
use Drupal\views\Views;
/**
* Tests the argument language handler.
......@@ -35,7 +36,7 @@ public static function getInfo() {
* Tests the language argument.
*/
public function testArgument() {
$view = views_get_view('test_view');
$view = Views::getView('test_view');
foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('arguments', array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\language\Tests\Views;
use Drupal\Core\Language\Language;
use Drupal\views\Views;
/**
* Tests the field language handler.
......@@ -35,7 +36,7 @@ public static function getInfo() {
* Tests the language field.
*/
public function testField() {
$view = views_get_view('test_view');
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('fields', array(
'langcode' => array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\language\Tests\Views;
use Drupal\Core\Language\Language;
use Drupal\views\Views;
/**
* Tests the filter language handler.
......@@ -35,7 +36,7 @@ public static function getInfo() {
* Tests the language filter.
*/
public function testFilter() {
$view = views_get_view('test_view');
$view = Views::getView('test_view');
foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;
/**
* Tests the Drupal\node\Plugin\views\field\Type handler.
*/
......@@ -38,7 +40,7 @@ public function testFieldType() {
'node_field_data_type' => 'node_field_data_type',
);
$view = views_get_view('test_field_type');
$view = Views::getView('test_field_type');
$this->executeView($view);
$this->assertIdenticalResultset($view, $expected_result, $column_map, 'The correct node type was displayed.');
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;
/**
* Tests the node_uid_revision handler.
*/
......@@ -53,7 +55,7 @@ public function testFilter() {
// or the main node.
$this->drupalCreateNode(array('uid' => $no_author->id()));
$view = views_get_view('test_filter_node_uid_revision');
$view = Views::getView('test_filter_node_uid_revision');
$view->initHandlers();
$view->filter['uid_revision']->value = array($author->id());
......
......@@ -9,6 +9,7 @@
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
/**
* Tests the default frontpage provided by views.
......@@ -53,7 +54,7 @@ public function testFrontPage() {
->set('name', $site_name)
->save();
$view = views_get_view('frontpage');
$view = Views::getView('frontpage');
$view->setDisplay('page_1');
$this->executeView($view);
$view->preview();
......
......@@ -6,6 +6,7 @@
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
......@@ -58,7 +59,7 @@ public function testNodeRevisionRelationship() {
);
// Here should be two rows.
$view_nid = views_get_view('test_node_revision_nid');
$view_nid = Views::getView('test_node_revision_nid');
$this->executeView($view_nid, array($node->id()));
$resultset_nid = array(
array(
......@@ -75,7 +76,7 @@ public function testNodeRevisionRelationship() {
$this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);
// There should be only one row with active revision 2.
$view_vid = views_get_view('test_node_revision_vid');
$view_vid = Views::getView('test_node_revision_vid');
$this->executeView($view_vid, array($node->id()));
$resultset_vid = array(
array(
......
......@@ -6,7 +6,9 @@
*/
namespace Drupal\node\Tests\Views;
use Drupal\Core\Language\Language;
use Drupal\views\Views;
/**
* Tests the node row plugin.
......@@ -109,7 +111,7 @@ public function drupalCreateComment(array $settings = array()) {
* Tests the node row plugin.
*/
public function testRowPlugin() {
$view = views_get_view('test_node_row_plugin');
$view = Views::getView('test_node_row_plugin');
$view->initDisplay();
$view->setDisplay('page_1');
$view->initStyle();
......
......@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests\Views;
use Drupal\views\Views;
use Drupal\views\Tests\Plugin\PluginTestBase;
use Drupal\views\Tests\ViewTestData;
......@@ -67,7 +68,7 @@ protected function setUp() {
*/
public function testSerializerResponses() {
// Test the serialize callback.
$view = views_get_view('test_serializer_display_field');
$view = Views::getView('test_serializer_display_field');
$view->initDisplay();
$this->executeView($view);
......@@ -104,7 +105,7 @@ public function testSerializerResponses() {
// Test the entity rows.
$view = views_get_view('test_serializer_display_entity');
$view = Views::getView('test_serializer_display_entity');
$view->initDisplay();
$this->executeView($view);
......@@ -186,7 +187,7 @@ public function testUIFieldAlias() {
$this->drupalPostForm($row_options, array('row_options[field_options][name][alias]' => ''), t('Apply'));
$this->drupalPostForm(NULL, array(), t('Save'));
$view = views_get_view('test_serializer_display_field');
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
$this->executeView($view);
......@@ -221,7 +222,7 @@ public function testUIFieldAlias() {
$this->drupalPostForm(NULL, array(), t('Save'));
$view = views_get_view('test_serializer_display_field');
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
$this->executeView($view);
......@@ -253,7 +254,7 @@ public function testFieldRawOutput() {
$this->drupalPostForm($row_options, array('row_options[field_options][created][raw_output]' => '1'), t('Apply'));
$this->drupalPostForm(NULL, array(), t('Save'));
$view = views_get_view('test_serializer_display_field');
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
$this->executeView($view);
......@@ -267,7 +268,7 @@ public function testFieldRawOutput() {
* Tests the preview output for json output.
*/
public function testPreview() {
$view = views_get_view('test_serializer_display_entity');
$view = Views::getView('test_serializer_display_entity');
$view->setDisplay('rest_export_1');
$this->executeView($view);
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
/**
* Tests the node_term_data relationship handler.
*/
......@@ -28,7 +30,7 @@ public static function getInfo() {
}
function testViewsHandlerRelationshipNodeTermData() {
$view = views_get_view('test_taxonomy_node_term_data');
$view = Views::getView('test_taxonomy_node_term_data');
$this->executeView($view, array($this->term1->id(), $this->term2->id()));
$resultset = array(
array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\views\Views;
/**
* Tests the representative node relationship for terms.
*/
......@@ -31,7 +33,7 @@ public static function getInfo() {
* Tests the relationship.
*/
public function testRelationship() {
$view = views_get_view('test_groupwise_term');
$view = Views::getView('test_groupwise_term');
$this->executeView($view);
$map = array('node_taxonomy_term_data_nid' => 'nid', 'tid' => 'tid');
$expected_result = array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\tracker\Tests\Views;
use Drupal\views\Views;
/**
* Tests the tracker user uid handlers.
*/
......@@ -43,7 +45,7 @@ public function testUserUid() {
)
);
$view = views_get_view('test_tracker_user_uid');
$view = Views::getView('test_tracker_user_uid');
$this->executeView($view);
// We should have no results as the filter is set for uid 0.
......
......@@ -8,6 +8,7 @@
namespace Drupal\user\Tests\Views;
use Drupal\user\Plugin\views\access\Permission;
use Drupal\views\Views;
/**
* Tests views perm access plugin.
......@@ -35,7 +36,7 @@ public static function getInfo() {
* Tests perm access plugin.
*/
function testAccessPerm() {
$view = views_get_view('test_access_perm');
$view = Views::getView('test_access_perm');
$view->setDisplay();
$access_plugin = $view->display_handler->getPlugin('access');
......
......@@ -7,6 +7,8 @@
namespace Drupal\user\Tests\Views;
use Drupal\views\Views;
/**
* Tests views user argument default plugin.
*/
......@@ -38,7 +40,7 @@ public function test_plugin_argument_default_current_user() {
drupal_save_session(FALSE);
$user = $account;
$view = views_get_view('test_plugin_argument_default_current_user');
$view = Views::getView('test_plugin_argument_default_current_user');
$view->initHandlers();
$this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.');
......
......@@ -7,6 +7,8 @@
namespace Drupal\user\Tests\Views;
use Drupal\views\Views;
/**
* Tests views user argument validator plugin.
*/
......@@ -83,7 +85,7 @@ function testArgumentValidateUserEither() {
}
function view_argument_validate_user($argtype) {
$view = views_get_view('test_view_argument_validate_user');
$view = Views::getView('test_view_argument_validate_user');
$view->setDisplay();
$view->displayHandlers->get('default')->options['arguments']['null']['validate_options']['type'] = $argtype;
$view->preExecute();
......
......@@ -7,6 +7,8 @@
namespace Drupal\user\Tests\Views;
use Drupal\views\Views;
/**
* Tests the views bulk form test.
*
......@@ -81,7 +83,7 @@ public function testBulkForm() {
$this->assertNoRaw($account->label(), 'The user is not found in the table.');
// Remove the user status filter from the view.
$view = views_get_view('test_user_bulk_form');
$view = Views::getView('test_user_bulk_form');
$view->removeHandler('default', 'filter', 'status');
$view->storage->save();
......
......@@ -7,6 +7,8 @@
namespace Drupal\user\Tests\Views;
use Drupal\views\Views;
/**
* Tests views user uid argument handler.
*/
......@@ -31,7 +33,7 @@ public static function getInfo() {
* Tests the generated title of an user: uid argument.