diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_default/RawTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_default/RawTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f866575440b8b2ecc9c82230b4145fb3eadacc35 --- /dev/null +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_default/RawTest.php @@ -0,0 +1,89 @@ + 'Argument default: Raw', + 'description' => 'Tests the raw argument default plugin.', + 'group' => 'Views Plugin', + ); + } + + /** + * Test the getArgument() method. + * + * @see \Drupal\views\Plugin\views\argument_default\Raw::getArgument() + */ + public function testGetArgument() { + $view = $this->getMockBuilder('Drupal\views\ViewExecutable') + ->disableOriginalConstructor() + ->getMock(); + $display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase') + ->disableOriginalConstructor() + ->getMock(); + + $request = new Request(array(), array(), array('system_path' => 'test/example')); + $alias_manager = $this->getMock('Drupal\Core\Path\AliasManagerInterface'); + $alias_manager->expects($this->never()) + ->method('getPathAlias'); + + // Don't use aliases. + $raw = new Raw(array(), 'raw', array(), $request, $alias_manager); + $options = array( + 'use_alias' => FALSE, + 'index' => 0, + ); + $raw->init($view, $display_plugin, $options); + $this->assertEquals('test', $raw->getArgument()); + + $raw = new Raw(array(), 'raw', array(), $request, $alias_manager); + $options = array( + 'use_alias' => FALSE, + 'index' => 1, + ); + $raw->init($view, $display_plugin, $options); + $this->assertEquals('example', $raw->getArgument()); + + // Setup an alias manager with a path alias. + $alias_manager = $this->getMock('Drupal\Core\Path\AliasManagerInterface'); + $alias_manager->expects($this->any()) + ->method('getPathAlias') + ->with($this->equalTo('test/example')) + ->will($this->returnValue('other/example')); + + $raw = new Raw(array(), 'raw', array(), $request, $alias_manager); + $options = array( + 'use_alias' => TRUE, + 'index' => 0, + ); + $raw->init($view, $display_plugin, $options); + $this->assertEquals('other', $raw->getArgument()); + + $raw = new Raw(array(), 'raw', array(), $request, $alias_manager); + $options = array( + 'use_alias' => TRUE, + 'index' => 1, + ); + $raw->init($view, $display_plugin, $options); + $this->assertEquals('example', $raw->getArgument()); + + } + +}