Skip to content

Commit

Permalink
GraphQL-84: Return URL Rewrites for products
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeriy Nayda committed Oct 3, 2018
1 parent 0fe1ae5 commit 7b8799d
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp()
}

/**
* Tests if target_path(relative_url) is resolved for Product entity
* Tests if target_path(canonical_url) is resolved for Product entity
*
* @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php
*/
Expand Down Expand Up @@ -60,20 +60,20 @@ public function testProductUrlResolver()
urlResolver(url:"{$urlPath}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}

/**
* Tests the use case where relative_url is provided as resolver input in the Query
* Tests the use case where canonical_url is provided as resolver input in the Query
*
* @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php
*/
Expand Down Expand Up @@ -104,15 +104,15 @@ public function testProductUrlWithCanonicalUrlInput()
urlResolver(url:"{$canonicalPath}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}

Expand Down Expand Up @@ -147,15 +147,15 @@ public function testCategoryUrlResolver()
urlResolver(url:"{$urlPath2}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($categoryId, $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}

Expand Down Expand Up @@ -183,14 +183,14 @@ public function testCMSPageUrlResolver()
urlResolver(url:"{$requestPath}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertEquals($cmsPageId, $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper(str_replace('-', '_', $expectedEntityType)), $response['urlResolver']['type']);
}

Expand Down Expand Up @@ -226,15 +226,15 @@ public function testProductUrlRewriteResolver()
urlResolver(url:"{$urlPath}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}

Expand Down Expand Up @@ -266,7 +266,7 @@ public function testInvalidUrlResolverInput()
urlResolver(url:"{$urlPath}")
{
id
relative_url
canonical_url
type
}
}
Expand Down Expand Up @@ -307,15 +307,15 @@ public function testCategoryUrlWithLeadingSlash()
urlResolver(url:"/{$urlPath}")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($categoryId, $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}

Expand Down Expand Up @@ -344,15 +344,15 @@ public function testResolveSlash()
urlResolver(url:"/")
{
id
relative_url
canonical_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($homePageId, $response['urlResolver']['id']);
$this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
$this->assertEquals('CMS_PAGE', $response['urlResolver']['type']);
}
}

0 comments on commit 7b8799d

Please sign in to comment.