Esempio n. 1
0
 /**
  * Tests LinkUri::transform().
  *
  * @param array $value
  *   The value to pass to LinkUri::transform().
  * @param string $expected
  *   The expected return value of LinkUri::transform().
  * @param \Drupal\Core\Url $url
  *   (optional) The URL that the path validator prophecy will return.
  *
  * @dataProvider providerTestTransform
  *
  * @covers ::transform
  */
 public function testTransform(array $value, $expected, Url $url = NULL)
 {
     $migrate_executable = $this->prophesize(MigrateExecutableInterface::class);
     $row = $this->prophesize(Row::class);
     if ($url) {
         $this->pathValidator->getUrlIfValidWithoutAccessCheck(reset($value))->willReturn($url);
     }
     $actual = $this->processPlugin->transform($value, $migrate_executable->reveal(), $row->reveal(), 'link/uri');
     $this->assertEquals($expected, $actual);
 }
 /**
  * Tests the getUrlIfValid() method with a front page + query + fragments.
  */
 public function testGetUrlIfValidWithFrontPageAndQueryAndFragments()
 {
     $url = $this->pathValidator->getUrlIfValid('<front>?hei=sen#berg');
     $this->assertEquals('<front>', $url->getRouteName());
     $this->assertEquals(['hei' => 'sen'], $url->getOptions()['query']);
     $this->assertEquals('berg', $url->getOptions()['fragment']);
 }
Esempio n. 3
0
 /**
  * Tests the getUrlIfValidWithoutAccessCheck() method.
  *
  * @covers ::getUrlIfValidWithoutAccessCheck
  */
 public function testGetUrlIfValidWithoutAccessCheck()
 {
     $this->account->expects($this->never())->method('hasPermission')->with('link to any page');
     $this->accessAwareRouter->expects($this->never())->method('match');
     $this->accessUnawareRouter->expects($this->once())->method('match')->with('/test-path')->willReturn([RouteObjectInterface::ROUTE_NAME => 'test_route', '_raw_variables' => new ParameterBag(['key' => 'value'])]);
     $this->pathProcessor->expects($this->once())->method('processInbound')->willReturnArgument(0);
     $url = $this->pathValidator->getUrlIfValidWithoutAccessCheck('test-path');
     $this->assertInstanceOf('Drupal\\Core\\Url', $url);
     $this->assertEquals('test_route', $url->getRouteName());
     $this->assertEquals(['key' => 'value'], $url->getRouteParameters());
 }