Commit a5c93987 authored by alexpott's avatar alexpott

Issue #2028041 by plopesc, dawehner: Move Argument Php to php module.

parent 165ec2ca
...@@ -2,21 +2,22 @@ ...@@ -2,21 +2,22 @@
/** /**
* @file * @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\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
/** /**
* Default argument plugin to provide a PHP code block. * Default argument plugin to provide a PHP code block.
* *
* @ingroup views_argument_default_plugins
*
* @Plugin( * @Plugin(
* id = "php", * id = "php",
* module = "php",
* title = @Translation("PHP Code") * title = @Translation("PHP Code")
* ) * )
*/ */
......
...@@ -2,21 +2,22 @@ ...@@ -2,21 +2,22 @@
/** /**
* @file * @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\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation; 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. * Provide PHP code to validate whether or not an argument is ok.
* *
* @ingroup views_argument_validate_plugins
*
* @Plugin( * @Plugin(
* id = "php", * id = "php",
* module = "php",
* title = @Translation("PHP Code") * title = @Translation("PHP Code")
* ) * )
*/ */
......
<?php
/**
* @file
* Contains \Drupal\php\Tests\Plugin\views\ArgumentValidatorTest.
*/
namespace Drupal\php\Tests\Plugin\views;
use Drupal\views\Tests\ViewUnitTestBase;
/**
* Tests Views argument validators.
*
* @see \Drupal\php\Plugin\views\argument_validator\Php
*/
class PhpArgumentValidatorTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view_argument_validate_php');
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('php');
public static function getInfo() {
return array(
'name' => '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()));
}
}
...@@ -19,7 +19,7 @@ class ArgumentValidatorTest extends ViewUnitTestBase { ...@@ -19,7 +19,7 @@ class ArgumentValidatorTest extends ViewUnitTestBase {
* *
* @var array * @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() { public static function getInfo() {
return array( return array(
...@@ -29,19 +29,6 @@ public static function getInfo() { ...@@ -29,19 +29,6 @@ public static function getInfo() {
); );
} }
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() { function testArgumentValidateNumeric() {
$view = views_get_view('test_view_argument_validate_numeric'); $view = views_get_view('test_view_argument_validate_numeric');
$view->initHandlers(); $view->initHandlers();
......
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