|
8 | 8 | namespace Magento\Checkout\Api;
|
9 | 9 |
|
10 | 10 | use Magento\Framework\Webapi\Rest\Request;
|
| 11 | +use Magento\Catalog\Test\Fixture\Product as ProductFixture; |
| 12 | +use Magento\Quote\Test\Fixture\GuestCart as GuestCartFixture; |
| 13 | +use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture; |
| 14 | +use Magento\Checkout\Test\Fixture\SetBillingAddress as SetBillingAddressFixture; |
| 15 | +use Magento\TestFramework\Fixture\DataFixture; |
11 | 16 | use Magento\TestFramework\TestCase\WebapiAbstract;
|
12 | 17 | use Magento\TestFramework\Helper\Bootstrap;
|
13 | 18 | use Magento\Quote\Model\Quote;
|
@@ -50,50 +55,14 @@ protected function setUp(): void
|
50 | 55 | $this->quoteIdMaskFactory = Bootstrap::getObjectManager()->get(QuoteIdMaskFactory::class);
|
51 | 56 | }
|
52 | 57 |
|
53 |
| - /** |
54 |
| - * Test validation of required fields in shipping address |
55 |
| - * |
56 |
| - * @magentoApiDataFixture Magento/Sales/_files/quote.php |
57 |
| - */ |
58 |
| - public function testSaveAddressInformationWithMissingRequiredFields() |
59 |
| - { |
60 |
| - $this->expectException(\Exception::class); |
61 |
| - $this->expectExceptionMessage('The shipping address contains invalid data'); |
62 |
| - $cartId = $this->getMaskedCartId('test01'); |
63 |
| - $shippingAddress = $this->addressFactory->create(); |
64 |
| - $shippingAddress->setData([ |
65 |
| - 'country_id' => 'US', |
66 |
| - 'region_id' => 12, |
67 |
| - 'region' => 'California', |
68 |
| - 'region_code' => 'CA', |
69 |
| - 'street' => ['123 Test Street'], |
70 |
| - 'city' => 'Test City', |
71 |
| - 'postcode' => '90210', |
72 |
| - 'telephone' => '1234567890' |
73 |
| - ]); |
74 |
| - $billingAddress = $this->addressFactory->create(); |
75 |
| - $billingAddress->setData([ |
76 |
| - 'country_id' => 'US', |
77 |
| - 'region_id' => 12, |
78 |
| - 'region' => 'California', |
79 |
| - 'region_code' => 'CA', |
80 |
| - 'street' => ['123 Test Street'], |
81 |
| - 'city' => 'Test City', |
82 |
| - 'postcode' => '90210', |
83 |
| - 'telephone' => '1234567890' |
84 |
| - ]); |
85 |
| - $shippingInformation = $this->shippingInformationFactory->create(); |
86 |
| - $shippingInformation->setShippingAddress($shippingAddress); |
87 |
| - $shippingInformation->setBillingAddress($billingAddress); |
88 |
| - $shippingInformation->setShippingMethodCode('flatrate'); |
89 |
| - $shippingInformation->setShippingCarrierCode('flatrate'); |
90 |
| - $this->callSaveAddressInformation($cartId, $shippingInformation); |
91 |
| - } |
92 |
| - |
| 58 | + #[ |
| 59 | + DataFixture(ProductFixture::class, as: 'p1'), |
| 60 | + DataFixture(GuestCartFixture::class, as: 'cart'), |
| 61 | + DataFixture(AddProductToCartFixture::class, ['cart_id' => '$cart.id$', 'product_id' => '$p1.id$']), |
| 62 | + DataFixture(SetBillingAddressFixture::class, ['cart_id' => '$cart.id$']), |
| 63 | + ] |
93 | 64 | /**
|
94 | 65 | * Test successful validation with valid address data
|
95 |
| - * |
96 |
| - * @magentoApiDataFixture Magento/Sales/_files/quote.php |
97 | 66 | */
|
98 | 67 | public function testSaveAddressInformationWithValidData()
|
99 | 68 | {
|
|
0 commit comments