Skip to content

Commit 28e9423

Browse files
authored
test(route_load): Add test for route_load language parameter (#1254)
1 parent 24f86e2 commit 28e9423

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

tests/src/Kernel/DataProducer/RoutingTest.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
*/
1414
class RoutingTest extends GraphQLTestBase {
1515

16+
/**
17+
* The redirect storage.
18+
*
19+
* @var \Drupal\Core\Entity\EntityStorageInterface
20+
*/
21+
protected $redirectStorage;
22+
1623
/**
1724
* {@inheritdoc}
1825
*/
1926
protected static $modules = [
2027
'redirect',
21-
'views',
2228
'path_alias',
29+
'views',
2330
];
2431

2532
/**
@@ -30,6 +37,8 @@ public function setUp(): void {
3037

3138
$this->installEntitySchema('redirect');
3239
$this->installConfig(['redirect']);
40+
41+
$this->redirectStorage = $this->container->get('entity_type.manager')->getStorage('redirect');
3342
}
3443

3544
/**
@@ -80,6 +89,35 @@ public function testRouteLoad(): void {
8089
$this->assertNull($result, 'Route to external URL should not be found.');
8190
}
8291

92+
/**
93+
* @covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Routing\RouteLoad::resolve
94+
*/
95+
public function testRedirectRouteLoad(): void {
96+
/** @var \Drupal\redirect\Entity\Redirect $redirect */
97+
$redirect = $this->redirectStorage->create();
98+
$redirect->setSource('redirect-url');
99+
$redirect->setRedirect('user/logout');
100+
$redirect->save();
101+
102+
$result = $this->executeDataProducer('route_load', [
103+
'path' => '/redirect-url',
104+
]);
105+
106+
$this->assertNotNull($result);
107+
$this->assertEquals('user.logout', $result->getRouteName());
108+
109+
$redirect->setLanguage('de');
110+
$redirect->save();
111+
112+
$result = $this->executeDataProducer('route_load', [
113+
'path' => '/redirect-url',
114+
'language' => 'de',
115+
]);
116+
117+
$this->assertNotNull($result);
118+
$this->assertEquals('user.logout', $result->getRouteName());
119+
}
120+
83121
/**
84122
* @covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Routing\Url\UrlPath::resolve
85123
*/

0 commit comments

Comments
 (0)