You are here

public function DrupalTest::testUrl in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testUrl()

Tests the url() method.

@covers ::url

See also

\Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 324
Contains \Drupal\Tests\Core\DrupalTest.

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

public function testUrl() {
  $route_parameters = array(
    'test_parameter' => 'test',
  );
  $options = array(
    'test_option' => 'test',
  );
  $generator = $this
    ->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
  $generator
    ->expects($this
    ->once())
    ->method('generateFromRoute')
    ->with('test_route', $route_parameters, $options)
    ->will($this
    ->returnValue('path_string'));
  $this
    ->setMockContainerService('url_generator', $generator);
  $this
    ->assertInternalType('string', \Drupal::url('test_route', $route_parameters, $options));
}