@@ -1401,109 +1401,6 @@ private function createPartialMockForAbstractClass(string $className, array $met
1401
1401
);
1402
1402
}
1403
1403
1404
- /**
1405
- * @return void
1406
- *
1407
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1408
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
1409
- */
1410
- public function testSubmitWithLockException (): void
1411
- {
1412
- $ orderData = [];
1413
- $ isGuest = true ;
1414
- $ isVirtual = false ;
1415
- $ customerId = 1 ;
1416
- $ quoteId = 1 ;
1417
- $ quoteItem = $ this ->createMock (Item::class);
1418
- $ billingAddress = $ this ->createMock (Address::class);
1419
- $ shippingAddress = $ this ->getMockBuilder (Address::class)
1420
- ->addMethods (['getQuoteId ' ])
1421
- ->onlyMethods (['getShippingMethod ' , 'getId ' ])
1422
- ->disableOriginalConstructor ()
1423
- ->getMock ();
1424
- $ payment = $ this ->createMock (Payment::class);
1425
- $ baseOrder = $ this ->getMockForAbstractClass (OrderInterface::class);
1426
- $ convertedBilling = $ this ->createPartialMockForAbstractClass (OrderAddressInterface::class, ['setData ' ]);
1427
- $ convertedShipping = $ this ->createPartialMockForAbstractClass (OrderAddressInterface::class, ['setData ' ]);
1428
- $ convertedPayment = $ this ->getMockForAbstractClass (OrderPaymentInterface::class);
1429
- $ convertedQuoteItem = $ this ->getMockForAbstractClass (OrderItemInterface::class);
1430
- $ addresses = [$ convertedShipping , $ convertedBilling ];
1431
- $ quoteItems = [$ quoteItem ];
1432
- $ convertedItems = [$ convertedQuoteItem ];
1433
- $ quote = $ this ->getQuote (
1434
- $ isGuest ,
1435
- $ isVirtual ,
1436
- $ billingAddress ,
1437
- $ payment ,
1438
- $ customerId ,
1439
- $ quoteId ,
1440
- $ quoteItems ,
1441
- $ shippingAddress ,
1442
- false
1443
- );
1444
-
1445
- $ this ->submitQuoteValidator ->expects ($ this ->once ())
1446
- ->method ('validateQuote ' )
1447
- ->with ($ quote );
1448
- $ this ->quoteAddressToOrder ->expects ($ this ->once ())
1449
- ->method ('convert ' )
1450
- ->with ($ shippingAddress , $ orderData )
1451
- ->willReturn ($ baseOrder );
1452
- $ this ->quoteAddressToOrderAddress
1453
- ->method ('convert ' )
1454
- ->willReturnCallback (function ($ arg1 , $ arg2 )
1455
- use ($ shippingAddress , $ billingAddress , $ convertedShipping , $ convertedBilling ) {
1456
- if ($ arg1 == $ shippingAddress &&
1457
- $ arg2 ['address_type ' ] == 'shipping ' &&
1458
- $ arg2 ['email ' ] == 'customer@example.com ' ) {
1459
- return $ convertedShipping ;
1460
- } elseif ($ arg1 == $ billingAddress &&
1461
- $ arg2 ['address_type ' ] == 'billing ' &&
1462
- $ arg2 ['email ' ] == 'customer@example.com ' ) {
1463
- return $ convertedBilling ;
1464
- }
1465
- });
1466
- $ billingAddress ->expects ($ this ->once ())->method ('getId ' )->willReturn (4 );
1467
- $ convertedBilling ->expects ($ this ->once ())->method ('setData ' )->with ('quote_address_id ' , 4 );
1468
-
1469
- $ this ->quoteItemToOrderItem ->expects ($ this ->once ())->method ('convert ' )
1470
- ->with ($ quoteItem , ['parent_item ' => null ])
1471
- ->willReturn ($ convertedQuoteItem );
1472
- $ this ->quotePaymentToOrderPayment ->expects ($ this ->once ())->method ('convert ' )->with ($ payment )
1473
- ->willReturn ($ convertedPayment );
1474
- $ shippingAddress ->expects ($ this ->once ())->method ('getShippingMethod ' )->willReturn ('free ' );
1475
- $ shippingAddress ->expects ($ this ->once ())->method ('getId ' )->willReturn (5 );
1476
- $ convertedShipping ->expects ($ this ->once ())->method ('setData ' )->with ('quote_address_id ' , 5 );
1477
- $ order = $ this ->prepareOrderFactory (
1478
- $ baseOrder ,
1479
- $ convertedBilling ,
1480
- $ addresses ,
1481
- $ convertedPayment ,
1482
- $ convertedItems ,
1483
- $ quoteId ,
1484
- $ convertedShipping
1485
- );
1486
-
1487
- $ this ->eventManager
1488
- ->method ('dispatch ' )
1489
- ->withConsecutive (
1490
- [
1491
- 'sales_model_service_quote_submit_before ' ,
1492
- ['order ' => $ order , 'quote ' => $ quote ]
1493
- ],
1494
- [
1495
- 'sales_model_service_quote_submit_success ' ,
1496
- ['order ' => $ order , 'quote ' => $ quote ]
1497
- ]
1498
- );
1499
- $ this ->lockManagerMock ->method ('lock ' )->willReturn (false );
1500
-
1501
- $ this ->expectExceptionMessage (
1502
- 'A server error stopped your order from being placed. Please try to place your order again. '
1503
- );
1504
- $ this ->assertEquals ($ order , $ this ->model ->submit ($ quote , $ orderData ));
1505
- }
1506
-
1507
1404
/**
1508
1405
* Invokes private method.
1509
1406
*
0 commit comments