20
20
use Magento \Framework \App \RequestInterface ;
21
21
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
22
22
use Magento \Quote \Api \CartRepositoryInterface ;
23
- use Magento \Quote \Api \CartManagementInterface ;
24
23
use Magento \Quote \Model \Quote ;
25
- use Magento \Quote \Model \Quote \Payment ;
26
- use Magento \Payment \Model \MethodInterface ;
27
24
use Magento \Quote \Model \Quote \Address ;
28
25
use Magento \Quote \Model \Quote \Item ;
29
- use Magento \Catalog \Model \Product ;
30
- use Magento \Catalog \Model \Product \Type \AbstractType ;
31
26
use Magento \Quote \Model \Quote \Item \Updater ;
32
27
use Magento \Quote \Model \QuoteFactory ;
33
28
use Magento \Sales \Model \AdminOrder \Create ;
44
39
*/
45
40
class CreateTest extends TestCase
46
41
{
47
- private const CUSTOMER_ID = 1 ;
42
+ const CUSTOMER_ID = 1 ;
48
43
49
44
/**
50
45
* @var Create
@@ -56,11 +51,6 @@ class CreateTest extends TestCase
56
51
*/
57
52
private $ quoteRepository ;
58
53
59
- /**
60
- * @var CartManagementInterface|MockObject
61
- */
62
- private $ quoteManagement ;
63
-
64
54
/**
65
55
* @var QuoteFactory|MockObject
66
56
*/
@@ -114,10 +104,6 @@ protected function setUp(): void
114
104
$ this ->formFactory = $ this ->createPartialMock (FormFactory::class, ['create ' ]);
115
105
$ this ->quoteFactory = $ this ->createPartialMock (QuoteFactory::class, ['create ' ]);
116
106
$ this ->customerFactory = $ this ->createPartialMock (CustomerInterfaceFactory::class, ['create ' ]);
117
- $ this ->quoteManagement = $ this ->getMockBuilder (CartManagementInterface::class)
118
- ->disableOriginalConstructor ()
119
- ->setMethods (['submit ' ])
120
- ->getMockForAbstractClass ();
121
107
122
108
$ this ->itemUpdater = $ this ->createMock (Updater::class);
123
109
@@ -131,7 +117,6 @@ protected function setUp(): void
131
117
->setMethods (
132
118
[
133
119
'getQuote ' ,
134
- 'getOrder ' ,
135
120
'getStoreId ' ,
136
121
'getCustomerId ' ,
137
122
'setData ' ,
@@ -149,8 +134,6 @@ protected function setUp(): void
149
134
$ storeMock = $ this ->getMockBuilder (StoreInterface::class)
150
135
->setMethods (['getId ' ])
151
136
->getMockForAbstractClass ();
152
- $ storeMock ->method ('getId ' )
153
- ->willReturn (1 );
154
137
$ this ->sessionQuote ->method ('getStore ' )
155
138
->willReturn ($ storeMock );
156
139
@@ -178,15 +161,6 @@ protected function setUp(): void
178
161
'getShippingAddress ' ,
179
162
'getBillingAddress ' ,
180
163
'getCouponCode ' ,
181
- 'getCustomerFirstname ' ,
182
- 'getCustomerLastname ' ,
183
- 'getCustomerMiddlename ' ,
184
- 'getIncrementId ' ,
185
- 'getOriginalIncrementId ' ,
186
- 'getEditIncrement ' ,
187
- 'setRelationChildId ' ,
188
- 'setRelationChildRealId ' ,
189
- 'save ' ,
190
164
]
191
165
)
192
166
->getMock ();
@@ -204,7 +178,6 @@ protected function setUp(): void
204
178
'dataObjectHelper ' => $ this ->dataObjectHelper ,
205
179
'quoteRepository ' => $ this ->quoteRepository ,
206
180
'quoteFactory ' => $ this ->quoteFactory ,
207
- 'quoteManagement ' => $ this ->quoteManagement ,
208
181
]
209
182
);
210
183
}
@@ -488,144 +461,4 @@ public function testInitFromOrder()
488
461
489
462
$ this ->adminOrderCreate ->initFromOrder ($ this ->orderMock );
490
463
}
491
-
492
- /**
493
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
494
- */
495
- public function testCreateOrder ()
496
- {
497
- $ method = $ this ->getMockBuilder (MethodInterface::class)
498
- ->disableOriginalConstructor ()
499
- ->setMethods (
500
- [
501
- 'isAvailable ' ,
502
- 'validate ' ,
503
- ]
504
- )
505
- ->getMockForAbstractClass ();
506
- $ method ->method ('isAvailable ' )
507
- ->willReturn (true );
508
- $ method ->method ('validate ' )
509
- ->willReturn (true );
510
- $ payment = $ this ->getMockBuilder (Payment::class)
511
- ->disableOriginalConstructor ()
512
- ->setMethods (
513
- [
514
- 'getMethod ' ,
515
- 'getMethodInstance ' ,
516
- ]
517
- )
518
- ->getMock ();
519
- $ payment ->method ('getMethod ' )
520
- ->willReturn ('checkmo ' );
521
- $ payment ->method ('getMethodInstance ' )
522
- ->willReturn ($ method );
523
-
524
- $ type = $ this ->getMockBuilder (AbstractType::class)
525
- ->disableOriginalConstructor ()
526
- ->setMethods (
527
- [
528
- 'getOrderOptions ' ,
529
- ]
530
- )
531
- ->getMockForAbstractClass ();
532
- $ type ->method ('getOrderOptions ' )
533
- ->willReturn (false );
534
-
535
- $ product = $ this ->getMockBuilder (Product::class)
536
- ->disableOriginalConstructor ()
537
- ->setMethods (
538
- [
539
- 'getTypeInstance ' ,
540
- ]
541
- )
542
- ->getMockForAbstractClass ();
543
- $ product ->method ('getTypeInstance ' )
544
- ->willReturn ($ type );
545
-
546
- $ item = $ this ->getMockBuilder (Item::class)
547
- ->disableOriginalConstructor ()
548
- ->setMethods (
549
- [
550
- 'getHasError ' ,
551
- 'getProduct ' ,
552
- 'getOptionByCode ' ,
553
- ]
554
- )
555
- ->getMockForAbstractClass ();
556
- $ item ->method ('getHasError ' )
557
- ->willReturn (false );
558
- $ item ->method ('getProduct ' )
559
- ->willReturn ($ product );
560
- $ item ->method ('getOptionByCode ' )
561
- ->willReturn (false );
562
- $ items = [
563
- $ item
564
- ];
565
-
566
- $ quote = $ this ->getMockBuilder (Quote::class)
567
- ->disableOriginalConstructor ()
568
- ->setMethods (
569
- [
570
- 'getCustomerIsGuest ' ,
571
- 'getAllItems ' ,
572
- 'isVirtual ' ,
573
- 'getPayment ' ,
574
- 'getItemById ' ,
575
- ]
576
- )
577
- ->getMock ();
578
- $ quote ->method ('getCustomerIsGuest ' )
579
- ->willReturn (true );
580
- $ quote ->method ('getAllItems ' )
581
- ->willReturn ($ items );
582
- $ quote ->method ('isVirtual ' )
583
- ->willReturn (true );
584
- $ quote ->method ('getPayment ' )
585
- ->willReturn ($ payment );
586
- $ quote ->method ('getItemById ' )
587
- ->willReturn ($ item );
588
-
589
- $ this ->sessionQuote
590
- ->method ('getQuote ' )
591
- ->willReturn ($ quote );
592
- $ this ->orderMock ->method ('getId ' )
593
- ->willReturn (1 );
594
- $ this ->orderMock ->method ('getCustomerFirstname ' )
595
- ->willReturn ('firstname ' );
596
- $ this ->orderMock ->method ('getCustomerLastname ' )
597
- ->willReturn ('lastname ' );
598
- $ this ->orderMock ->method ('getCustomerMiddlename ' )
599
- ->willReturn ('middlename ' );
600
- $ this ->orderMock ->method ('getIncrementId ' )
601
- ->willReturn ('100000001 ' );
602
- $ this ->orderMock ->method ('getEditIncrement ' )
603
- ->willReturn (0 );
604
- $ this ->sessionQuote
605
- ->method ('getOrder ' )
606
- ->willReturn ($ this ->orderMock );
607
-
608
- $ guestOrder = $ this ->getMockBuilder (Order::class)
609
- ->disableOriginalConstructor ()
610
- ->setMethods (
611
- [
612
- 'getId ' ,
613
- 'getIncrementId ' ,
614
- 'getCustomerIsGuest ' ,
615
- 'save ' ,
616
- ]
617
- )
618
- ->getMock ();
619
- $ guestOrder ->method ('getId ' )
620
- ->willReturn (2 );
621
- $ guestOrder ->method ('getIncrementId ' )
622
- ->willReturn ('100000001-1 ' );
623
- $ guestOrder ->method ('getCustomerIsGuest ' )
624
- ->willReturn (true );
625
- $ this ->quoteManagement ->method ('submit ' )
626
- ->willReturn ($ guestOrder );
627
-
628
- $ object = $ this ->adminOrderCreate ->createOrder ();
629
- self ::assertEquals ($ this ->orderMock ->getCustomerFirstname (), $ object ->getCustomerFirstname ());
630
- }
631
464
}
0 commit comments