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

8.0.x
Alex Pott 2013-06-29 23:38:08 +01:00
parent 165ec2ca55
commit a5c939875b
4 changed files with 68 additions and 22 deletions

View File

@ -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")
* )
*/

View File

@ -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")
* )
*/

View File

@ -0,0 +1,57 @@
<?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()));
}
}

View File

@ -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();