Skip to content

Commit f55229e

Browse files
committed
API-functional tests progress
1 parent 59e452f commit f55229e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerDownloadableProduct/CustomerDownloadableProductTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
namespace Magento\GraphQl\CustomerDownloadableProduct;
99

1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
11+
use Magento\TestFramework\ObjectManager;
12+
use Magento\Customer\Api\CustomerRepositoryInterface;
13+
use Magento\Sales\Api\OrderRepositoryInterface;
14+
use Magento\Framework\Api\SearchCriteriaBuilder;
1115

1216
class CustomerDownloadableProductTest extends GraphQlAbstract
1317
{
18+
1419
/**
1520
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1621
* @magentoApiDataFixture Magento/Customer/_files/customer.php
1722
* @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php
23+
* @magentoApiDataFixture Magento/Downloadable/_files/order_with_downloadable_product.php
1824
*/
1925
public function testGetCustomerDownloadableProducts()
2026
{
@@ -46,7 +52,49 @@ public function testGetCustomerDownloadableProducts()
4652
4753
}
4854
QUERY;
55+
$objectManager = ObjectManager::getInstance();
56+
57+
$searchCriteria = $objectManager->get(SearchCriteriaBuilder::class)->create();
58+
59+
$orderRepository = $objectManager->create(OrderRepositoryInterface::class);
60+
$orders = $orderRepository->getList($searchCriteria)->getItems();
61+
$order = array_pop($orders);
62+
63+
$builder = $objectManager->create(\Magento\Framework\Api\FilterBuilder::class);
64+
$filter = $builder
65+
->setField('email')
66+
->setValue('customer@example.com');
67+
68+
$searchCriteria = $objectManager->get(
69+
SearchCriteriaBuilder::class
70+
)->addFilter(
71+
'email',
72+
'customer@example.com'
73+
)->create();
74+
75+
$customerRepository = $objectManager->create(CustomerRepositoryInterface::class);
76+
$customers = $customerRepository->getList($searchCriteria)
77+
->getItems();
78+
$customer = array_pop($customers);
79+
80+
$order->setCustomerId($customer->getId())->setCustomerIsGuest(false)->save();
4981

5082
$response = $this->graphQlQuery($query, [], '', $this->headers);
83+
84+
$expectedResponse = [
85+
'customerDownloadableProducts' => [
86+
'items' => [
87+
[
88+
'order_increment_id' => $order->getIncrementId(),
89+
'date' => '',
90+
'status' => 'pending',
91+
'download_url' => 'http://example.com/downloadable.txt',
92+
'remaining_downloads' => '1'
93+
]
94+
]
95+
]
96+
];
97+
98+
$this->assertEquals($expectedResponse, $response);
5199
}
52100
}

0 commit comments

Comments
 (0)