RoutingTest.php in GraphQL 8.4
File
tests/src/Kernel/DataProducer/RoutingTest.php
View source
<?php
namespace Drupal\Tests\graphql\Kernel\DataProducer;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
class RoutingTest extends GraphQLTestBase {
public function testRouteLoad() : void {
$result = $this
->executeDataProducer('route_load', [
'path' => '/user/logout',
]);
$this
->assertNotNull($result);
$this
->assertEquals('user.logout', $result
->getRouteName());
}
public function testUrlPath() : void {
$this->pathValidator = $this->container
->get('path.validator');
$url = $this->pathValidator
->getUrlIfValidWithoutAccessCheck('/user/logout');
$result = $this
->executeDataProducer('url_path', [
'url' => $url,
]);
$this
->assertEquals('/user/logout', $result);
}
public function testUrlNotFound() : void {
$result = $this
->executeDataProducer('route_load', [
'path' => '/idontexist',
]);
$this
->assertNull($result);
}
}