Skip to content

Commit d6eee26

Browse files
committed
MC-17875: Refactor GraphQl Integration tests
- code review comments
1 parent 74cbfb3 commit d6eee26

15 files changed

+30
-86
lines changed

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
use Magento\Framework\HTTP\ZendClientFactory;
1717
use Magento\TestFramework\ObjectManager;
1818
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
19-
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
2019
use PHPUnit\Framework\MockObject\MockObject;
21-
use Magento\Quote\Model\Quote\PaymentFactory;
2220
use PHPUnit\Framework\TestCase;
2321
use Zend_Http_Response;
2422

@@ -27,14 +25,13 @@
2725
*
2826
* @magentoAppArea graphql
2927
* @magentoDbIsolation disabled
30-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3128
*/
3229
class PlaceOrderWithAuthorizeNetTest extends TestCase
3330
{
34-
/** @var ObjectManager */
31+
/** @var ObjectManager */
3532
private $objectManager;
3633

37-
/** @var GetMaskedQuoteIdByReservedOrderId */
34+
/** @var GetMaskedQuoteIdByReservedOrderId */
3835
private $getMaskedQuoteIdByReservedOrderId;
3936

4037
/** @var SerializerInterface */
@@ -46,15 +43,12 @@ class PlaceOrderWithAuthorizeNetTest extends TestCase
4643
/** @var ZendClient|MockObject|InvocationMocker */
4744
private $clientMock;
4845

49-
/** @var CustomerTokenServiceInterface */
46+
/** @var CustomerTokenServiceInterface */
5047
private $customerTokenService;
5148

5249
/** @var Zend_Http_Response */
5350
protected $responseMock;
5451

55-
/** @var PaymentFactory */
56-
private $paymentFactory;
57-
5852
protected function setUp() : void
5953
{
6054
$this->objectManager = Bootstrap::getObjectManager();
@@ -71,8 +65,6 @@ protected function setUp() : void
7165
$clientFactoryMock = $this->createMock(ZendClientFactory::class);
7266
$clientFactoryMock->method('create')
7367
->willReturn($this->clientMock);
74-
/** @var PaymentDataObjectFactory $paymentFactory */
75-
$this->paymentFactory = $this->objectManager->get(PaymentDataObjectFactory::class);
7668
$this->objectManager->addSharedInstance($clientFactoryMock, ZendClientFactory::class);
7769
}
7870

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/SetAuthorizeNetPaymentMethodOnCartTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class SetAuthorizeNetPaymentMethodOnCartTest extends TestCase
2626
/** @var \Magento\Framework\ObjectManagerInterface */
2727
private $objectManager;
2828

29-
/** @var GetMaskedQuoteIdByReservedOrderId */
29+
/** @var GetMaskedQuoteIdByReservedOrderId */
3030
private $getMaskedQuoteIdByReservedOrderId;
3131

3232
/** @var SerializerInterface */
3333
private $jsonSerializer;
3434

35-
/** @var CustomerTokenServiceInterface */
35+
/** @var CustomerTokenServiceInterface */
3636
private $customerTokenService;
3737

3838
/** @var GraphQlRequest */

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/PlaceOrderWithAuthorizeNetTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\AuthorizenetGraphQl\Model\Resolver\Guest;
99

10-
use Magento\Framework\App\Request\Http;
1110
use Magento\Framework\Serialize\SerializerInterface;
1211
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1312
use Magento\GraphQl\Service\GraphQlRequest;
@@ -16,9 +15,7 @@
1615
use Magento\Framework\HTTP\ZendClientFactory;
1716
use Magento\TestFramework\ObjectManager;
1817
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
19-
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
2018
use PHPUnit\Framework\MockObject\MockObject;
21-
use Magento\Quote\Model\Quote\PaymentFactory;
2219
use PHPUnit\Framework\TestCase;
2320
use Zend_Http_Response;
2421

@@ -27,14 +24,13 @@
2724
*
2825
* @magentoAppArea graphql
2926
* @magentoDbIsolation disabled
30-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3127
*/
3228
class PlaceOrderWithAuthorizeNetTest extends TestCase
3329
{
34-
/** @var ObjectManager */
30+
/** @var ObjectManager */
3531
private $objectManager;
3632

37-
/** @var GetMaskedQuoteIdByReservedOrderId */
33+
/** @var GetMaskedQuoteIdByReservedOrderId */
3834
private $getMaskedQuoteIdByReservedOrderId;
3935

4036
/** @var SerializerInterface */
@@ -49,15 +45,10 @@ class PlaceOrderWithAuthorizeNetTest extends TestCase
4945
/** @var Zend_Http_Response */
5046
protected $responseMock;
5147

52-
/** @var PaymentFactory */
53-
private $paymentFactory;
54-
5548
protected function setUp() : void
5649
{
5750
$this->objectManager = Bootstrap::getObjectManager();
58-
$this->graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
5951
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
60-
$this->request = $this->objectManager->get(Http::class);
6152
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
6253
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
6354
$this->clientMock = $this->createMock(ZendClient::class);
@@ -69,8 +60,6 @@ protected function setUp() : void
6960
$clientFactoryMock = $this->createMock(ZendClientFactory::class);
7061
$clientFactoryMock->method('create')
7162
->willReturn($this->clientMock);
72-
/** @var PaymentDataObjectFactory $paymentFactory */
73-
$this->paymentFactory = $this->objectManager->get(PaymentDataObjectFactory::class);
7463
$this->objectManager->addSharedInstance($clientFactoryMock, ZendClientFactory::class);
7564
}
7665

dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/SetAuthorizeNetPaymentMethodOnCartTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SetAuthorizeNetPaymentMethodOnCartTest extends TestCase
2626
/** @var ObjectManager */
2727
private $objectManager;
2828

29-
/** @var GetMaskedQuoteIdByReservedOrderId */
29+
/** @var GetMaskedQuoteIdByReservedOrderId */
3030
private $getMaskedQuoteIdByReservedOrderId;
3131

3232
/** @var SerializerInterface */

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressSetPaymentMethodTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\PaypalGraphQl\Model\Resolver\Customer;
99

10-
use Magento\GraphQl\Service\GraphQlRequest;
1110
use Magento\Paypal\Model\Api\Nvp;
1211
use Magento\PaypalGraphQl\PaypalExpressAbstractTest;
1312
use Magento\Framework\Serialize\SerializerInterface;
@@ -21,11 +20,6 @@
2120
*/
2221
class PaypalExpressSetPaymentMethodTest extends PaypalExpressAbstractTest
2322
{
24-
/**
25-
* @var GraphQlRequest
26-
*/
27-
private $graphQlRequest;
28-
2923
/**
3024
* @var SerializerInterface
3125
*/
@@ -42,7 +36,6 @@ protected function setUp()
4236

4337
$this->json = $this->objectManager->get(SerializerInterface::class);
4438
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
45-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4639
}
4740

4841
/**

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressTokenTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\PaypalGraphQl\Model\Resolver\Customer;
99

10-
use Magento\GraphQl\Service\GraphQlRequest;
1110
use Magento\Paypal\Model\Api\Nvp;
1211
use Magento\PaypalGraphQl\PaypalExpressAbstractTest;
1312
use Magento\Framework\Serialize\SerializerInterface;
@@ -20,11 +19,6 @@
2019
*/
2120
class PaypalExpressTokenTest extends PaypalExpressAbstractTest
2221
{
23-
/**
24-
* @var GraphQlRequest
25-
*/
26-
private $graphQlRequest;
27-
2822
/**
2923
* @var SerializerInterface
3024
*/
@@ -41,7 +35,6 @@ protected function setUp()
4135

4236
$this->json = $this->objectManager->get(SerializerInterface::class);
4337
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
44-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4538
}
4639

4740
/**

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowProTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\PaypalGraphQl\Model\Resolver\Customer;
99

10-
use Magento\GraphQl\Service\GraphQlRequest;
1110
use Magento\PaypalGraphQl\PaypalPayflowProAbstractTest;
1211
use Magento\Framework\Serialize\SerializerInterface;
1312
use Magento\Quote\Model\QuoteIdToMaskedQuoteId;
@@ -21,11 +20,6 @@
2120
*/
2221
class PlaceOrderWithPayflowProTest extends PaypalPayflowProAbstractTest
2322
{
24-
/**
25-
* @var GraphQlRequest
26-
*/
27-
private $graphQlRequest;
28-
2923
/**
3024
* @var SerializerInterface
3125
*/
@@ -42,13 +36,13 @@ protected function setUp()
4236

4337
$this->json = $this->objectManager->get(SerializerInterface::class);
4438
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
45-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4639
}
4740

4841
/**
4942
* Test end to end test to process a paypal payflow pro order
5043
*
5144
* @return void
45+
* @magentoDataFixture Magento/Sales/_files/default_rollback.php
5246
* @magentoDataFixture Magento/Customer/_files/customer.php
5347
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
5448
* @magentoDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressSetPaymentMethodTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77

88
namespace Magento\PaypalGraphQl\Model\Resolver\Guest;
99

10-
use Magento\Framework\App\Request\Http;
11-
use Magento\GraphQl\Service\GraphQlRequest;
1210
use Magento\Paypal\Model\Api\Nvp;
1311
use Magento\PaypalGraphQl\PaypalExpressAbstractTest;
1412
use Magento\Framework\Serialize\SerializerInterface;
1513
use Magento\Quote\Model\QuoteIdToMaskedQuoteId;
16-
use Magento\TestFramework\Helper\Bootstrap;
1714
use Magento\Framework\UrlInterface;
1815

1916
/**
@@ -23,11 +20,6 @@
2320
*/
2421
class PaypalExpressSetPaymentMethodTest extends PaypalExpressAbstractTest
2522
{
26-
/**
27-
* @var GraphQlRequest
28-
*/
29-
private $graphQlRequest;
30-
3123
/**
3224
* @var SerializerInterface
3325
*/
@@ -44,7 +36,6 @@ protected function setUp()
4436

4537
$this->json = $this->objectManager->get(SerializerInterface::class);
4638
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
47-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4839
}
4940

5041
/**
@@ -53,6 +44,7 @@ protected function setUp()
5344
* @param string $paymentMethod
5445
* @return void
5546
* @dataProvider getPaypalCodesProvider
47+
* @magentoDataFixture Magento/Sales/_files/default_rollback.php
5648
* @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
5749
* @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
5850
* @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressTokenTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
12-
use Magento\GraphQl\Service\GraphQlRequest;
1312
use Magento\Paypal\Model\Api\Nvp;
1413
use Magento\PaypalGraphQl\PaypalExpressAbstractTest;
1514
use Magento\Framework\Serialize\SerializerInterface;
@@ -22,11 +21,6 @@
2221
*/
2322
class PaypalExpressTokenTest extends PaypalExpressAbstractTest
2423
{
25-
/**
26-
* @var GraphQlRequest
27-
*/
28-
private $graphQlRequest;
29-
3024
/**
3125
* @var SerializerInterface
3226
*/
@@ -43,7 +37,6 @@ protected function setUp()
4337

4438
$this->json = $this->objectManager->get(SerializerInterface::class);
4539
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
46-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4740
}
4841

4942
/**

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalPayflowProSetPaymentMethodTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\PaypalGraphQl\Model\Resolver\Guest;
99

10-
use Magento\GraphQl\Service\GraphQlRequest;
1110
use Magento\PaypalGraphQl\PaypalPayflowProAbstractTest;
1211
use Magento\Framework\Serialize\SerializerInterface;
1312
use Magento\Quote\Model\QuoteIdToMaskedQuoteId;
@@ -21,11 +20,6 @@
2120
*/
2221
class PaypalPayflowProSetPaymentMethodTest extends PaypalPayflowProAbstractTest
2322
{
24-
/**
25-
* @var GraphQlRequest
26-
*/
27-
private $graphQlRequest;
28-
2923
/**
3024
* @var SerializerInterface
3125
*/
@@ -42,7 +36,6 @@ protected function setUp()
4236

4337
$this->json = $this->objectManager->get(SerializerInterface::class);
4438
$this->quoteIdToMaskedId = $this->objectManager->get(QuoteIdToMaskedQuoteId::class);
45-
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
4639
}
4740

4841
/**

0 commit comments

Comments
 (0)