From a5c939875b4c2c19f092541dc0da2c3d0a041bab Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sat, 29 Jun 2013 23:38:08 +0100 Subject: [PATCH] Issue #2028041 by plopesc, dawehner: Move Argument Php to php module. --- .../Plugin/views/argument_default/Php.php | 9 +-- .../Plugin/views/argument_validator/Php.php | 9 +-- .../Plugin/views/PhpArgumentValidatorTest.php | 57 +++++++++++++++++++ .../Tests/Plugin/ArgumentValidatorTest.php | 15 +---- 4 files changed, 68 insertions(+), 22 deletions(-) rename core/modules/{views/lib/Drupal/views => php/lib/Drupal/php}/Plugin/views/argument_default/Php.php (89%) rename core/modules/{views/lib/Drupal/views => php/lib/Drupal/php}/Plugin/views/argument_validator/Php.php (88%) create mode 100644 core/modules/php/lib/Drupal/php/Tests/Plugin/views/PhpArgumentValidatorTest.php diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Php.php b/core/modules/php/lib/Drupal/php/Plugin/views/argument_default/Php.php similarity index 89% rename from core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Php.php rename to core/modules/php/lib/Drupal/php/Plugin/views/argument_default/Php.php index 2fc8c38e5eb..1377dec1aaa 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument_default/Php.php +++ b/core/modules/php/lib/Drupal/php/Plugin/views/argument_default/Php.php @@ -2,21 +2,22 @@ /** * @file - * Definition of Drupal\views\Plugin\views\argument_default\Php. + * Contains \Drupal\php\Plugin\views\argument_default\Php. */ -namespace Drupal\views\Plugin\views\argument_default; +namespace Drupal\php\Plugin\views\argument_default; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; + /** * Default argument plugin to provide a PHP code block. * - * @ingroup views_argument_default_plugins - * * @Plugin( * id = "php", + * module = "php", * title = @Translation("PHP Code") * ) */ diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Php.php b/core/modules/php/lib/Drupal/php/Plugin/views/argument_validator/Php.php similarity index 88% rename from core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Php.php rename to core/modules/php/lib/Drupal/php/Plugin/views/argument_validator/Php.php index 138a1dff1e9..057ea4baee1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Php.php +++ b/core/modules/php/lib/Drupal/php/Plugin/views/argument_validator/Php.php @@ -2,21 +2,22 @@ /** * @file - * Definition of Drupal\views\Plugin\views\argument_validator\Php. + * Contains \Drupal\views\Plugin\views\argument_validator\Php. */ -namespace Drupal\views\Plugin\views\argument_validator; +namespace Drupal\php\Plugin\views\argument_validator; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase; + /** * Provide PHP code to validate whether or not an argument is ok. * - * @ingroup views_argument_validate_plugins - * * @Plugin( * id = "php", + * module = "php", * title = @Translation("PHP Code") * ) */ diff --git a/core/modules/php/lib/Drupal/php/Tests/Plugin/views/PhpArgumentValidatorTest.php b/core/modules/php/lib/Drupal/php/Tests/Plugin/views/PhpArgumentValidatorTest.php new file mode 100644 index 00000000000..29f59ca351f --- /dev/null +++ b/core/modules/php/lib/Drupal/php/Tests/Plugin/views/PhpArgumentValidatorTest.php @@ -0,0 +1,57 @@ + 'PHP argument validator', + 'group' => 'Views Plugins', + 'description' => 'Test PHP argument validator.', + ); + } + + /** + * Tests the validateArgument question. + */ + public function testArgumentValidatePhp() { + $string = $this->randomName(); + $view = views_get_view('test_view_argument_validate_php'); + $view->setDisplay(); + $view->displayHandlers->get('default')->options['arguments']['null']['validate_options']['code'] = 'return $argument == \''. $string .'\';'; + + $view->initHandlers(); + $this->assertTrue($view->argument['null']->validateArgument($string)); + // Reset saved argument validation. + $view->argument['null']->argument_validated = NULL; + $this->assertFalse($view->argument['null']->validateArgument($this->randomName())); + } + +} diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php index c22efacb9a9..85449906265 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php @@ -19,7 +19,7 @@ class ArgumentValidatorTest extends ViewUnitTestBase { * * @var array */ - public static $testViews = array('test_view_argument_validate_php', 'test_view_argument_validate_numeric'); + public static $testViews = array('test_view_argument_validate_numeric'); public static function getInfo() { return array( @@ -29,19 +29,6 @@ class ArgumentValidatorTest extends ViewUnitTestBase { ); } - function testArgumentValidatePhp() { - $string = $this->randomName(); - $view = views_get_view('test_view_argument_validate_php'); - $view->setDisplay(); - $view->displayHandlers->get('default')->options['arguments']['null']['validate_options']['code'] = 'return $argument == \''. $string .'\';'; - - $view->initHandlers(); - $this->assertTrue($view->argument['null']->validateArgument($string)); - // Reset safed argument validation. - $view->argument['null']->argument_validated = NULL; - $this->assertFalse($view->argument['null']->validateArgument($this->randomName())); - } - function testArgumentValidateNumeric() { $view = views_get_view('test_view_argument_validate_numeric'); $view->initHandlers();