Commit f95db7d4 authored by webchick's avatar webchick

Issue #1875960 by dawehner: Replaced globals with state() in views tests.

parent 52748d9f
......@@ -37,12 +37,13 @@ protected function setUp() {
* Tests render functionality.
*/
public function testRender() {
$GLOBALS['views_render.test'] = 0;
state()->set('views_render.test', 0);
// Make sure that the rendering just calls the preprocess function once.
$view = views_get_view('test_view_render');
$view->preview();
$this->assertEqual($GLOBALS['views_render.test'], 1);
$this->assertEqual(state()->get('views_render.test'), 1);
}
}
......@@ -28,8 +28,8 @@ protected function setUp() {
parent::setUp();
// Define the schema and views data variable before enabling the test module.
$GLOBALS['views_test_data_schema'] = $this->schemaDefinition();
$GLOBALS['views_test_data_views_data'] = $this->viewsData();
state()->set('views_test_data_schema', $this->schemaDefinition());
state()->set('views_test_data_views_data', $this->viewsData());
$this->enableModules(array('views', 'views_test_config', 'views_test_data'));
......
......@@ -9,11 +9,6 @@
* Implements hook_schema().
*/
function views_test_data_schema() {
// \Drupal\views\Tests\ViewUnitTestBase uses $GLOBALS, while
// \Drupal\views\Tests\ViewTestBase uses state().
if (isset($GLOBALS['views_test_data_schema'])) {
return $GLOBALS['views_test_data_schema'];
}
return state()->get('views_test_data_schema');
}
......
......@@ -23,11 +23,6 @@ function views_test_data_permission() {
* Implements hook_views_data().
*/
function views_test_data_views_data() {
// \Drupal\views\Tests\ViewUnitTestBase uses $GLOBALS, while
// \Drupal\views\Tests\ViewTestBase uses state().
if (isset($GLOBALS['views_test_data_views_data'])) {
return $GLOBALS['views_test_data_views_data'];
}
return state()->get('views_test_data_views_data');
}
......@@ -97,7 +92,9 @@ function views_test_data_views_pre_render(ViewExecutable $view) {
*/
function views_test_data_preprocess_views_view_table(&$variables) {
if ($variables['view']->storage->get('name') == 'test_view_render') {
$GLOBALS['views_render.test']++;
$views_render_test = state()->get('views_render.test');
$views_render_test++;
state()->set('views_render.test', $views_render_test);
}
}
......
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