Commit ec4c2322 authored by aspilicious's avatar aspilicious Committed by tim.plunkett

converted test plugins

parent 2842bc14
......@@ -9,7 +9,6 @@
use Drupal\simpletest\WebTestBase;
use Drupal\views\View;
use views_test_plugin_access_test_dynamic;
/**
* Basic test for pluggable access.
......@@ -37,27 +36,6 @@ public function setUp() {
views_fetch_plugin_data(NULL, NULL, TRUE);
}
function viewsPlugins() {
$plugins = array(
'access' => array(
'test_static' => array(
'title' => t('Static test access plugin'),
'help' => t('Provides a static test access plugin.'),
'handler' => 'views_test_plugin_access_test_static',
'path' => drupal_get_path('module', 'views_test') . '/test_plugins',
),
'test_dynamic' => array(
'title' => t('Dynamic test access plugin'),
'help' => t('Provides a dynamic test access plugin.'),
'handler' => 'views_test_plugin_access_test_dynamic',
'path' => drupal_get_path('module', 'views_test') . '/test_plugins',
),
),
);
return $plugins;
}
/**
* Tests none access plugin.
*/
......
......@@ -23,28 +23,10 @@ public static function getInfo() {
);
}
/**
* The views plugin definition. Override it if you test provides a plugin.
*/
public function viewsPlugins() {
return array(
'localization' => array(
'test' => array(
'no_ui' => TRUE,
'title' => t('Test'),
'help' => t('This is a test description.'),
'handler' => 'views_plugin_localization_test',
'parent' => 'parent',
'path' => drupal_get_path('module', 'views') .'/tests',
),
),
);
}
public function setUp() {
parent::setUp();
config('views.settings')->set('views_localization_plugin', 'test')->save();
config('views.settings')->set('views_localization_plugin', 'localization_test')->save();
// Reset the plugin data.
views_fetch_plugin_data(NULL, NULL, TRUE);
$this->strings = array('Master1', 'Apply1', 'Sort By1', 'Asc1', 'Desc1', 'more1', 'Reset1', 'Offset1', 'Master1', 'title1', 'Items per page1', 'fieldlabel1', 'filterlabel1');
......@@ -58,7 +40,10 @@ public function testUnpackTranslatable() {
$view = $this->view_unpack_translatable();
$view->init_localization();
$this->assertEqual('views_plugin_localization_test', get_class($view->localization_plugin), 'Make sure that init_localization initializes the right translation plugin');
// localization_plugin returns the plugin_id from the plugin
// get_class will go kaboom on a plugin_id I guess...
// TODO: fix this with anotation magic
$this->assertEqual('LocalizationTest', get_class($view->localization_plugin), 'Make sure that init_localization initializes the right translation plugin');
$view->export_locale_strings();
......
......@@ -22,7 +22,6 @@ protected function setUp() {
// Define the schema and views data variable before enabling the test module.
variable_set('views_test_schema', $this->schemaDefinition());
variable_set('views_test_views_data', $this->viewsData());
variable_set('views_test_views_plugins', $this->viewsPlugins());
module_enable(array('views_test'));
$this->resetAll();
......@@ -206,10 +205,6 @@ protected function viewsData() {
return $data;
}
protected function viewsPlugins() {
return array();
}
/**
* A very simple test dataset.
*/
......
......@@ -2,13 +2,23 @@
/**
* @file
* Definition of views_test_plugin_access_test_dynamic.
* Definition of Drupal\views_test\Plugin\views\access\DynamicTest.
*/
namespace Drupal\views_test\Plugin\views\access;
use Drupal\views\Plugin\views\access\AccessPluginBase;
/**
* Tests a dynamic access plugin.
*
* @Plugin(
* plugin_id = "test_dynamic",
* title = @Translation("Dynamic test access plugin."),
* help = @Translation("Provides a dynamic test access plugin.")
* )
*/
class views_test_plugin_access_test_dynamic extends views_plugin_access {
class DynamicTest extends AccessPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['access'] = array('default' => FALSE, 'bool' => TRUE);
......
......@@ -2,13 +2,23 @@
/**
* @file
* Definition of views_test_plugin_access_test_static.
* Definition of Drupal\views_test\Plugin\views\access\StaticTest.
*/
namespace Drupal\views_test\Plugin\views\access;
use Drupal\views\Plugin\views\access\AccessPluginBase;
/**
* Tests a static access plugin.
*
* @Plugin(
* plugin_id = "test_static",
* title = @Translation("Static test access plugin"),
* help = @Translation("Provides a static test access plugin.")
* )
*/
class views_test_plugin_access_test_static extends views_plugin_access {
class StaticTest extends AccessPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['access'] = array('default' => FALSE, 'bool' => TRUE);
......
......@@ -2,13 +2,24 @@
/**
* @file
* Definition of views_plugin_localization_test.
* Definition of Drupal\views_test\Plugin\views\localization\LocalizationTest.
*/
namespace Drupal\views_test\Plugin\views\localization;
use Drupal\views\Plugin\views\localization\LocalizationPluginBase;
/**
* A stump localisation plugin which has static variables to cache the input.
*
* @Plugin(
* plugin_id = "test_localization",
* title = @Translation("Test."),
* help = @Translation("This is a test description."),
* no_uid = TRUE
* )
*/
class views_plugin_localization_test extends views_plugin_localization {
class LocalizationTest extends LocalizationPluginBase {
/**
* Store the strings which was translated.
*/
......
......@@ -191,7 +191,4 @@ files[] = modules/user/views_plugin_argument_validate_user.inc
files[] = modules/user/views_plugin_row_user_view.inc
; Tests
files[] = tests/test_plugins/views_test_plugin_access_test_dynamic.inc
files[] = tests/test_plugins/views_test_plugin_access_test_static.inc
files[] = tests/views_plugin_localization_test.inc
files[] = tests/views_test.views_default.inc
files[] = tests/views_test/views_test.views_default.inc
......@@ -1384,10 +1384,10 @@ function views_get_localization_plugin() {
// Provide sane default values for the localization plugin.
if (empty($plugin)) {
if (module_exists('locale')) {
$plugin = 'Core';
$plugin = 'core';
}
else {
$plugin = 'None';
$plugin = 'none';
}
}
......
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