Skip to content

Commit

Permalink
cbf
Browse files Browse the repository at this point in the history
  • Loading branch information
dbosen committed May 7, 2024
1 parent 241a421 commit 15921ac
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modules/thunder_gqls/tests/src/Functional/RedirectSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class RedirectSchemaTest extends ThunderGqlsTestBase {
*/
protected $unpublishedEntity;

/**
* The redirect query.
*
* @var string
*/
protected $query;
/**
* {@inheritdoc}
*/
Expand All @@ -26,21 +32,21 @@ protected function setUp(): void {

$this->unpublishedEntity = $this->loadNodeByUuid('94ad928b-3ec8-4bcb-b617-ab1607bf69cb');
$this->unpublishedEntity->set('moderation_state', 'unpublished')->save();
$this->query = $this->getQueryFromFile('redirect');
}

/**
* Test redirect to alias, depending on redirect settings.
*/
public function testAlias(): void {
$query = $this->getQueryFromFile('redirect');
$path = '/node/' . $this->loadNodeByUuid('36b2e2b2-3df0-43eb-a282-d792b0999c07')->id();
$variables = Json::encode(['path' => $path]);

$this->config('redirect.settings')
->set('route_normalizer_enabled', TRUE)
->save();

$response = $this->query($query, $variables);
$response = $this->query($this->query, $variables);
$this->assertEquals(200, $response->getStatusCode(), 'Response not 200');

$redirectResponseData = Json::decode($response->getBody())['data']['redirect'];
Expand All @@ -58,7 +64,7 @@ public function testAlias(): void {
// Rebuild caches.
$this->container->get('cache.graphql.results')->deleteAll();

$response = $this->query($query, $variables);
$response = $this->query($this->query, $variables);
$this->assertEquals(200, $response->getStatusCode(), 'Response not 200');

$redirectResponseData = Json::decode($response->getBody())['data']['redirect'];
Expand All @@ -77,12 +83,11 @@ public function testAlias(): void {
*/
public function testRedirect(): void {
$testCases = $this->redirectTestCases();
$query = $this->getQueryFromFile('redirect');

foreach ($testCases as $description => $testCase) {
[$variables, $expectedResponse] = $testCase;

$response = $this->query($query, Json::encode($variables));
$response = $this->query($this->query, Json::encode($variables));
$this->assertEquals(200, $response->getStatusCode(), 'Response not 200');

$redirectResponseData = Json::decode($response->getBody())['data']['redirect'];
Expand Down

0 comments on commit 15921ac

Please sign in to comment.