public function FieldRedirectionResultUnitTest::testFromUrl in Field Redirection 8.2
@covers ::fromUrl
File
- tests/
src/ Unit/ FieldRedirectionResultUnitTest.php, line 24
Class
- FieldRedirectionResultUnitTest
- Defines a class for testing FieldRedirectionResult.
Namespace
Drupal\Tests\field_redirection\UnitCode
public function testFromUrl() {
$unroutedUrlAssembler = $this
->prophesize(UnroutedUrlAssemblerInterface::class);
$url = 'http://example.com';
$unroutedUrlAssembler
->assemble(Argument::cetera())
->willReturn($url);
$redirect = FieldRedirectionResult::fromUrl(Url::fromUri($url)
->setUnroutedUrlAssembler($unroutedUrlAssembler
->reveal()));
$this
->assertInstanceOf(FieldRedirectionResult::class, $redirect);
$this
->assertTrue($redirect
->shouldRedirect());
$expected = new RedirectResponse($url);
$this
->assertEquals($expected, $redirect
->asRedirectResponse());
$expected = new RedirectResponse($url, 301);
$this
->assertEquals($expected, $redirect
->asRedirectResponse(301));
}