Skip to content

Commit 1deb86f

Browse files
committed
ACQE-8551: [Web API Automation] - AC-8424
- Apply PR feedback to new test code: modern fixtures, no single-use vars, -> assertions
1 parent 2e7f4e0 commit 1deb86f

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
1717
use Magento\TestFramework\Helper\Bootstrap;
1818
use Magento\TestFramework\TestCase\GraphQlAbstract;
19+
use Magento\TestFramework\Fixture\Config;
20+
use Magento\TestFramework\Fixture\DataFixture;
1921

2022
/**
2123
* End to checkout tests for guest
@@ -90,17 +92,16 @@ public function testCheckoutWorkflow()
9092
/**
9193
* Test checkout workflow with null second street in shipping address
9294
* Validates that null values in street array are properly filtered and don't cause errors
93-
*
94-
* @magentoConfigFixture default_store checkout/options/guest_checkout 1
95-
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
9695
*/
96+
#[
97+
Config('default_store', 'checkout/options/guest_checkout', 1),
98+
DataFixture('Magento/Catalog/_files/products_with_layered_navigation_attribute.php')
99+
]
97100
public function testCheckoutWithNullSecondStreetInShippingAddress()
98101
{
99-
$quantity = 1;
100-
$sku = $this->findProduct();
101102
$cartId = $this->createEmptyCart();
102103
$this->setGuestEmailOnCart($cartId);
103-
$this->addProductToCart($cartId, $quantity, $sku);
104+
$this->addProductToCart($cartId, 1, $this->findProduct());
104105

105106
$shippingMethod = $this->setShippingAddressWithNullSecondStreet($cartId);
106107

@@ -478,31 +479,31 @@ private function setShippingAddressWithNullSecondStreet(string $cartId): array
478479

479480
$response = $this->graphQlMutation($query);
480481

481-
self::assertArrayHasKey('setShippingAddressesOnCart', $response);
482-
self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
483-
self::assertArrayHasKey('shipping_addresses', $response['setShippingAddressesOnCart']['cart']);
484-
self::assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
482+
$this->assertArrayHasKey('setShippingAddressesOnCart', $response);
483+
$this->assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
484+
$this->assertArrayHasKey('shipping_addresses', $response['setShippingAddressesOnCart']['cart']);
485+
$this->assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
485486

486487
$shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
487488

488-
self::assertEquals('B', $shippingAddress['firstname']);
489-
self::assertEquals('C', $shippingAddress['lastname']);
490-
self::assertNull($shippingAddress['company']);
491-
self::assertEquals(['Lorem ipsum dolor sit ame'], $shippingAddress['street']);
492-
self::assertEquals('PARIS', $shippingAddress['city']);
493-
self::assertEquals('56590', $shippingAddress['postcode']);
494-
self::assertEquals('FR', $shippingAddress['country']['code']);
495-
self::assertEquals('FR', $shippingAddress['country']['label']);
496-
self::assertEquals('0601020304', $shippingAddress['telephone']);
489+
$this->assertEquals('B', $shippingAddress['firstname']);
490+
$this->assertEquals('C', $shippingAddress['lastname']);
491+
$this->assertNull($shippingAddress['company']);
492+
$this->assertEquals(['Lorem ipsum dolor sit ame'], $shippingAddress['street']);
493+
$this->assertEquals('PARIS', $shippingAddress['city']);
494+
$this->assertEquals('56590', $shippingAddress['postcode']);
495+
$this->assertEquals('FR', $shippingAddress['country']['code']);
496+
$this->assertEquals('FR', $shippingAddress['country']['label']);
497+
$this->assertEquals('0601020304', $shippingAddress['telephone']);
497498

498-
self::assertArrayHasKey('available_shipping_methods', $shippingAddress);
499-
self::assertGreaterThan(0, count($shippingAddress['available_shipping_methods']));
499+
$this->assertArrayHasKey('available_shipping_methods', $shippingAddress);
500+
$this->assertGreaterThan(0, count($shippingAddress['available_shipping_methods']));
500501

501502
$availableShippingMethod = current($shippingAddress['available_shipping_methods']);
502-
self::assertArrayHasKey('carrier_code', $availableShippingMethod);
503-
self::assertNotEmpty($availableShippingMethod['carrier_code']);
504-
self::assertArrayHasKey('method_code', $availableShippingMethod);
505-
self::assertNotEmpty($availableShippingMethod['method_code']);
503+
$this->assertArrayHasKey('carrier_code', $availableShippingMethod);
504+
$this->assertNotEmpty($availableShippingMethod['carrier_code']);
505+
$this->assertArrayHasKey('method_code', $availableShippingMethod);
506+
$this->assertNotEmpty($availableShippingMethod['method_code']);
506507

507508
return $availableShippingMethod;
508509
}

0 commit comments

Comments
 (0)