Commit ea77909c authored by catch's avatar catch

Issue #2021831 by plopesc: Replace usage of Views:: in tests with its own services.

parent 02782894
......@@ -10,7 +10,6 @@
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\Plugin\views\filter\InOperator;
use Drupal\views\Views;
/**
* Creates views with instances of all handlers...
......@@ -56,7 +55,7 @@ public static function getInfo() {
*/
public function testHandlers() {
$object_types = array_keys(ViewExecutable::viewsHandlerTypes());
foreach (Views::viewsData()->get() as $base_table => $info) {
foreach ($this->container->get('views.views_data')->get() as $base_table => $info) {
if (!isset($info['table']['base'])) {
continue;
}
......
......@@ -11,7 +11,6 @@
* Tests basic functions from the Views module.
*/
use Drupal\views\Plugin\views\filter\Standard;
use Drupal\views\Views;
class ModuleTest extends ViewUnitTestBase {
......@@ -51,7 +50,7 @@ public function testViewsGetHandler() {
'table' => $this->randomName(),
'field' => $this->randomName(),
);
$handler = Views::handlerManager($type)->getHandler($item);
$handler = $this->container->get('plugin.manager.views.' . $type)->getHandler($item);
$this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), t('Make sure that a broken handler of type: @type are created', array('@type' => $type)));
}
......@@ -66,7 +65,7 @@ public function testViewsGetHandler() {
);
foreach ($data as $id => $field_data) {
if (!in_array($id, array('title', 'help'))) {
$handler = Views::handlerManager($id)->getHandler($item);
$handler = $this->container->get('plugin.manager.views.' . $id)->getHandler($item);
$this->assertInstanceHandler($handler, $table, $field, $id);
}
}
......@@ -78,7 +77,7 @@ public function testViewsGetHandler() {
'table' => 'views_test_data',
'field' => 'job',
);
$handler = Views::handlerManager('filter')->getHandler($item, 'standard');
$handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard');
$this->assertTrue($handler instanceof Standard);
// @todo Reinstate these tests when the debug() in views_get_handler() is
......@@ -91,7 +90,7 @@ public function testViewsGetHandler() {
'table' => 'views_test_data',
'field' => 'field_invalid',
);
Views::handlerManager('field')->getHandler($item);
$this->container->get('plugin.manager.views.field')->getHandler($item);
$this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'))) !== FALSE, 'An invalid field name throws a debug message.');
unset($this->lastErrorMessage);
......@@ -99,7 +98,7 @@ public function testViewsGetHandler() {
'table' => 'table_invalid',
'field' => 'id',
);
Views::handlerManager('filter')->getHandler($item);
$this->container->get('plugin.manager.views.filter')->getHandler($item);
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
unset($this->lastErrorMessage);
......@@ -108,7 +107,7 @@ public function testViewsGetHandler() {
'field' => 'id',
'optional' => FALSE,
);
Views::handlerManager('filter')->getHandler($item);
$this->container->get('plugin.manager.views.filter')->getHandler($item);
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
unset($this->lastErrorMessage);
......@@ -117,7 +116,7 @@ public function testViewsGetHandler() {
'field' => 'id',
'optional' => TRUE,
);
Views::handlerManager('filter')->getHandler($item);
$this->container->get('plugin.manager.views.filter')->getHandler($item);
$this->assertFalse($this->lastErrorMessage, "An optional handler does not throw a debug message.");
unset($this->lastErrorMessage);
......@@ -238,7 +237,7 @@ function testStatusFunctions() {
public function testViewsFetchPluginNames() {
// All style plugins should be returned, as we have not specified a type.
$plugins = views_fetch_plugin_names('style');
$definitions = Views::pluginManager('style')->getDefinitions();
$definitions = $this->container->get('plugin.manager.views.style')->getDefinitions();
$expected = array();
foreach ($definitions as $id =>$definition) {
$expected[$id] = $definition['title'];
......@@ -282,7 +281,7 @@ protected function formatViewOptions(array $views = array()) {
* Ensure that a certain handler is a instance of a certain table/field.
*/
function assertInstanceHandler($handler, $table, $field, $id) {
$table_data = Views::viewsData()->get($table);
$table_data = $this->container->get('views.views_data')->get($table);
$field_data = $table_data[$field][$id];
$this->assertEqual($field_data['id'], $handler->getPluginId());
......
......@@ -7,7 +7,6 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin;
/**
......@@ -60,7 +59,7 @@ protected function viewsData() {
*/
public function testFilterQuery() {
// Check that we can find the test filter plugin.
$plugin = Views::pluginManager('filter')->createInstance('test_filter');
$plugin = $this->container->get('plugin.manager.views.filter')->createInstance('test_filter');
$this->assertTrue($plugin instanceof FilterPlugin, 'Test filter plugin found.');
$view = views_get_view('test_filter');
......
......@@ -7,7 +7,6 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\join\JoinTest as JoinTestPlugin;
use Drupal\views\Plugin\views\join\JoinPluginBase;
......@@ -46,7 +45,7 @@ protected function setUp() {
parent::setUp();
// Add a join plugin manager which can be used in all of the tests.
$this->manager = Views::pluginManager('join');
$this->manager = $this->container->get('plugin.manager.views.join');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment