77
88namespace Magento \Sales \Model ;
99
10+ use Magento \TestFramework \Fixture \Config ;
1011use PHPUnit \Framework \TestCase ;
1112use Magento \Framework \ObjectManagerInterface ;
1213use Magento \Sales \Api \CreditmemoRepositoryInterface ;
1617use Magento \Store \Api \Data \StoreInterface ;
1718use Magento \TestFramework \Fixture \DataFixture ;
1819use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
20+ use Magento \Quote \Api \CartManagementInterface ;
21+ use Magento \Quote \Api \CartRepositoryInterface ;
22+ use Magento \Checkout \Test \Fixture \SetBillingAddress ;
23+ use Magento \Checkout \Test \Fixture \SetShippingAddress ;
24+ use Magento \Checkout \Test \Fixture \SetDeliveryMethod ;
25+ use Magento \Checkout \Test \Fixture \SetPaymentMethod ;
26+ use Magento \Checkout \Test \Fixture \PlaceOrder ;
27+ use Magento \Sales \Test \Fixture \Invoice ;
28+ use Magento \Sales \Test \Fixture \Creditmemo ;
29+ use Magento \Framework \Api \SearchCriteriaBuilder ;
30+ use Magento \Store \Test \Fixture \Website ;
31+ use Magento \Store \Test \Fixture \Group ;
32+ use Magento \Store \Test \Fixture \Store ;
33+ use Magento \Catalog \Test \Fixture \Product ;
34+ use Magento \Customer \Test \Fixture \Customer ;
1935
2036/**
2137 * Integration test for complete workflow:
2238 * Create website, store, and store view with numeric names -> Place orders -> Create credit memo -> Verify grid display
2339 *
2440 * @magentoDbIsolation disabled
2541 * @magentoAppIsolation enabled
26- * @magentoConfigFixture default/general/country/allow US
27- * @magentoConfigFixture default/general/country/default US
28- * @magentoConfigFixture default_store carriers/flatrate/active 1
29- * @magentoConfigFixture default_store carriers/flatrate/price 5.00
30- * @magentoConfigFixture default_store payment/free/active 1
42+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3143 */
3244class StoreWithNumericNameCreditmemoWorkflowTest extends TestCase
3345{
@@ -57,18 +69,19 @@ protected function setUp(): void
5769 * @return void
5870 */
5971 #[
72+ Config('general/country/allow ' , 'US ' , 'default ' ),
73+ Config('general/country/default ' , 'US ' , 'default ' ),
74+ Config('carriers/flatrate/active ' , '1 ' , 'store ' , 'default ' ),
75+ Config('carriers/flatrate/price ' , '5.00 ' , 'store ' , 'default ' ),
76+ Config('payment/checkmo/active ' , '1 ' , 'store ' , 'default ' ),
77+ DataFixture(Website::class, ['code ' => 'test_website ' , 'name ' => '123test Website ' ], 'test_website ' ),
6078 DataFixture(
61- 'Magento\Store\Test\Fixture\Website ' ,
62- ['code ' => 'test_website ' , 'name ' => '123test Website ' ],
63- 'test_website '
64- ),
65- DataFixture(
66- 'Magento\Store\Test\Fixture\Group ' ,
79+ Group::class,
6780 ['code ' => 'test_group ' , 'name ' => '123test Store Group ' , 'website_id ' => '$test_website.id$ ' ],
6881 'test_group '
6982 ),
7083 DataFixture(
71- ' Magento\ Store\Test\Fixture\Store ' ,
84+ Store::class ,
7285 [
7386 'code ' => 'test_store ' ,
7487 'name ' => '123test Store View ' ,
@@ -78,12 +91,12 @@ protected function setUp(): void
7891 'test_store '
7992 ),
8093 DataFixture(
81- ' Magento\Catalog\Test\Fixture\ Product' ,
94+ Product::class ,
8295 ['sku ' => 'simple ' , 'price ' => 10 , 'website_ids ' => [1 , '$test_website.id$ ' ]],
8396 'product '
8497 ),
8598 DataFixture(
86- ' Magento\ Customer\Test\Fixture\Customer ' ,
99+ Customer::class ,
87100 ['email ' => 'customer@123test.com ' , 'website_id ' => '$test_website.id$ ' ],
88101 'customer '
89102 ),
@@ -98,8 +111,8 @@ public function testCompleteWorkflowWithNumericStoreNames(): void
98111 $ product = $ fixtures ->get ('product ' );
99112
100113 // Step 2: Create cart manually with correct store ID (CustomerCartFixture doesn't support store_id)
101- $ cartManagement = $ this ->objectManager ->get (' Magento\Quote\Api\ CartManagementInterface' );
102- $ cartRepository = $ this ->objectManager ->get (' Magento\Quote\Api\ CartRepositoryInterface' );
114+ $ cartManagement = $ this ->objectManager ->get (CartManagementInterface::class );
115+ $ cartRepository = $ this ->objectManager ->get (CartRepositoryInterface::class );
103116
104117 $ cartId = $ cartManagement ->createEmptyCartForCustomer ($ customer ->getId ());
105118 $ cart = $ cartRepository ->get ($ cartId );
@@ -111,27 +124,27 @@ public function testCompleteWorkflowWithNumericStoreNames(): void
111124 $ cartRepository ->save ($ cart );
112125
113126 // Step 3: Use fixtures for checkout process
114- $ billingAddressFixture = $ this ->objectManager ->create (' Magento\Checkout\Test\Fixture\ SetBillingAddress' );
127+ $ billingAddressFixture = $ this ->objectManager ->create (SetBillingAddress::class );
115128 $ billingAddressFixture ->apply (['cart_id ' => $ cart ->getId ()]);
116129
117- $ shippingAddressFixture = $ this ->objectManager ->create (' Magento\Checkout\Test\Fixture\ SetShippingAddress' );
130+ $ shippingAddressFixture = $ this ->objectManager ->create (SetShippingAddress::class );
118131 $ shippingAddressFixture ->apply (['cart_id ' => $ cart ->getId ()]);
119132
120- $ deliveryMethodFixture = $ this ->objectManager ->create (' Magento\Checkout\Test\Fixture\ SetDeliveryMethod' );
133+ $ deliveryMethodFixture = $ this ->objectManager ->create (SetDeliveryMethod::class );
121134 $ deliveryMethodFixture ->apply (
122135 ['cart_id ' => $ cart ->getId (), 'carrier_code ' => 'flatrate ' , 'method_code ' => 'flatrate ' ]
123136 );
124137
125- $ paymentMethodFixture = $ this ->objectManager ->create (' Magento\Checkout\Test\Fixture\ SetPaymentMethod' );
138+ $ paymentMethodFixture = $ this ->objectManager ->create (SetPaymentMethod::class );
126139 $ paymentMethodFixture ->apply (['cart_id ' => $ cart ->getId ()]);
127140
128- $ placeOrderFixture = $ this ->objectManager ->create (' Magento\Checkout\Test\Fixture\ PlaceOrder' );
141+ $ placeOrderFixture = $ this ->objectManager ->create (PlaceOrder::class );
129142 $ order = $ placeOrderFixture ->apply (['cart_id ' => $ cart ->getId ()]);
130143
131- $ invoiceFixture = $ this ->objectManager ->create (' Magento\Sales\Test\Fixture\ Invoice' );
144+ $ invoiceFixture = $ this ->objectManager ->create (Invoice::class );
132145 $ invoiceFixture ->apply (['order_id ' => $ order ->getId ()]);
133146
134- $ creditmemoFixture = $ this ->objectManager ->create (' Magento\Sales\Test\Fixture\ Creditmemo' );
147+ $ creditmemoFixture = $ this ->objectManager ->create (Creditmemo::class );
135148 $ creditmemo = $ creditmemoFixture ->apply ([
136149 'order_id ' => $ order ->getId (),
137150 'items ' => [['qty ' => 1 , 'product_id ' => $ product ->getId ()]]
@@ -218,7 +231,7 @@ private function verifyCreditMemoGridDisplaysRecords(
218231 */
219232 private function getCreditmemosByFilter (string $ field , mixed $ value ): array
220233 {
221- $ searchCriteria = $ this ->objectManager ->get (' Magento\Framework\Api\ SearchCriteriaBuilder' )
234+ $ searchCriteria = $ this ->objectManager ->get (SearchCriteriaBuilder::class )
222235 ->addFilter ($ field , $ value )
223236 ->create ();
224237
0 commit comments