Skip to content

Commit fde15ce

Browse files
committed
MAGETWO-88631: Pr sprint 10 delivery
- fix tests - refactor
1 parent 65aa40f commit fde15ce

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

app/code/Magento/GraphQl/Controller/HttpRequestProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class HttpRequestProcessor
2222
/**
2323
* @param HttpHeaderProcessorInterface[] $graphQlHeaders
2424
*/
25-
public function __construct(array $graphQlHeaders)
25+
public function __construct(array $graphQlHeaders = [])
2626
{
2727
$this->headerProcessors = $graphQlHeaders;
2828
}

dev/tests/integration/testsuite/Magento/GraphQl/Controller/GraphQlControllerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Tests the dispatch method in the GraphQl Controller class using a simple product query
1818
*
1919
* @magentoAppArea graphql
20-
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
20+
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
2121
*/
2222

2323
class GraphQlControllerTest extends \PHPUnit\Framework\TestCase
@@ -50,20 +50,20 @@ protected function setUp()
5050
}
5151

5252
/**
53-
* Tests if a graphql schema is generated and request is dispatched and response generated
53+
* Tests if a graphql schema is generated and request is dispatched and response generated
5454
*/
5555
public function testDispatch()
5656
{
5757
/** @var ProductRepositoryInterface $productRepository */
5858
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
5959

6060
/** @var ProductInterface $product */
61-
$product = $productRepository->get('simple');
61+
$product = $productRepository->get('simple1');
6262

6363
$query
6464
= <<<QUERY
6565
{
66-
products(filter: {sku: {eq: "simple"}})
66+
products(filter: {sku: {eq: "simple1"}})
6767
{
6868
items {
6969
id
@@ -88,6 +88,7 @@ public function testDispatch()
8888
$response = $this->graphql->dispatch($request);
8989
$output = $this->jsonSerializer->unserialize($response->getContent());
9090
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
91+
$this->assertTrue(count($output['data']['products']['items']) > 0, 'Products array has items');
9192
$this->assertEquals($output['data']['products']['items'][0]['id'], $product->getData($linkField));
9293
$this->assertEquals($output['data']['products']['items'][0]['sku'], $product->getSku());
9394
$this->assertEquals($output['data']['products']['items'][0]['name'], $product->getName());

lib/internal/Magento/Framework/GraphQl/Config/Element/Argument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ public function getDescription() : string
159159
/**
160160
* Return defaultValue if argument is a scalar and has a configured defaultValue. Otherwise return an empty string.
161161
*
162-
* @return string
162+
* @return string|null
163163
*/
164-
public function getDefaultValue() : string
164+
public function getDefaultValue() : ?string
165165
{
166166
return $this->defaultValue;
167167
}

lib/internal/Magento/Framework/GraphQl/Schema/Type/Entity/DefaultMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DefaultMapper implements MapperInterface
2020
/**
2121
* @param array $map
2222
*/
23-
public function __construct(array $map)
23+
public function __construct(array $map = [])
2424
{
2525
$this->map = $map;
2626
}

0 commit comments

Comments
 (0)