1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Core\Checkout\Test\Customer\Rule; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice; |
6
|
|
|
use Shopware\Core\Checkout\Cart\Price\Struct\CartPrice; |
7
|
|
|
use Shopware\Core\Checkout\Cart\Price\Struct\QuantityPriceDefinition; |
8
|
|
|
use Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection; |
9
|
|
|
use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection; |
10
|
|
|
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryStates; |
11
|
|
|
use Shopware\Core\Checkout\Order\OrderStates; |
12
|
|
|
use Shopware\Core\Defaults; |
13
|
|
|
use Shopware\Core\Framework\Context; |
14
|
|
|
use Shopware\Core\Framework\Test\TestCaseBase\BasicTestDataBehaviour; |
15
|
|
|
use Shopware\Core\Framework\Uuid\Uuid; |
16
|
|
|
use Shopware\Core\System\StateMachine\StateMachineRegistry; |
17
|
|
|
use Shopware\Core\System\Test\EntityFixturesBase; |
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
19
|
|
|
|
20
|
|
|
trait OrderFixture |
21
|
|
|
{ |
22
|
|
|
use ContainerAwareTrait; |
23
|
|
|
use EntityFixturesBase; |
24
|
|
|
use BasicTestDataBehaviour; |
25
|
|
|
|
26
|
|
|
private function getOrderData(string $orderId, Context $context): array |
27
|
|
|
{ |
28
|
|
|
$stateMachineRegistry = $this->getContainer()->get(StateMachineRegistry::class); |
29
|
|
|
$orderCustomerId = Uuid::randomHex(); |
30
|
|
|
$addressId = Uuid::randomHex(); |
31
|
|
|
$orderLineItemId = Uuid::randomHex(); |
32
|
|
|
$countryStateId = Uuid::randomHex(); |
33
|
|
|
$customerId = Uuid::randomHex(); |
34
|
|
|
|
35
|
|
|
$order = [ |
36
|
|
|
[ |
37
|
|
|
'id' => $orderId, |
38
|
|
|
'price' => new CartPrice(10, 10, 10, new CalculatedTaxCollection(), new TaxRuleCollection(), CartPrice::TAX_STATE_NET), |
39
|
|
|
'shippingCosts' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
40
|
|
|
'stateId' => $stateMachineRegistry->getInitialState(OrderStates::STATE_MACHINE, $context)->getId(), |
41
|
|
|
'paymentMethodId' => $this->getValidPaymentMethodId(), |
42
|
|
|
'currencyId' => Defaults::CURRENCY, |
43
|
|
|
'currencyFactor' => 1, |
44
|
|
|
'salesChannelId' => Defaults::SALES_CHANNEL, |
45
|
|
|
'orderDate' => '2019-04-01 08:36:43.267', |
46
|
|
|
'deliveries' => [ |
47
|
|
|
[ |
48
|
|
|
'stateId' => $stateMachineRegistry->getInitialState(OrderDeliveryStates::STATE_MACHINE, $context)->getId(), |
49
|
|
|
'shippingMethodId' => $this->getValidShippingMethodId(), |
50
|
|
|
'shippingCosts' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
51
|
|
|
'shippingDateEarliest' => date(DATE_ISO8601), |
52
|
|
|
'shippingDateLatest' => date(DATE_ISO8601), |
53
|
|
|
'shippingOrderAddress' => [ |
54
|
|
|
'salutationId' => $this->getValidSalutationId(), |
55
|
|
|
'firstName' => 'Floy', |
56
|
|
|
'lastName' => 'Glover', |
57
|
|
|
'zipcode' => '59438-0403', |
58
|
|
|
'city' => 'Stellaberg', |
59
|
|
|
'street' => 'street', |
60
|
|
|
'country' => [ |
61
|
|
|
'name' => 'kasachstan', |
62
|
|
|
'id' => $this->getValidCountryId(), |
63
|
|
|
], |
64
|
|
|
], |
65
|
|
|
'positions' => [ |
66
|
|
|
[ |
67
|
|
|
'price' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
68
|
|
|
'orderLineItemId' => $orderLineItemId, |
69
|
|
|
], |
70
|
|
|
], |
71
|
|
|
], |
72
|
|
|
], |
73
|
|
|
'lineItems' => [ |
74
|
|
|
[ |
75
|
|
|
'id' => $orderLineItemId, |
76
|
|
|
'identifier' => 'test', |
77
|
|
|
'quantity' => 1, |
78
|
|
|
'type' => 'test', |
79
|
|
|
'label' => 'test', |
80
|
|
|
'price' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
81
|
|
|
'priceDefinition' => new QuantityPriceDefinition(10, new TaxRuleCollection(), 2), |
82
|
|
|
'priority' => 100, |
83
|
|
|
'good' => true, |
84
|
|
|
], |
85
|
|
|
], |
86
|
|
|
'deepLinkCode' => 'BwvdEInxOHBbwfRw6oHF1Q_orfYeo9RY', |
87
|
|
|
'orderCustomerId' => $orderCustomerId, |
88
|
|
|
'orderCustomer' => [ |
89
|
|
|
'id' => $orderCustomerId, |
90
|
|
|
'email' => '[email protected]', |
91
|
|
|
'firstName' => 'Noe', |
92
|
|
|
'lastName' => 'Hill', |
93
|
|
|
'salutationId' => $this->getValidSalutationId(), |
94
|
|
|
'title' => 'Doc', |
95
|
|
|
'customerNumber' => 'Test', |
96
|
|
|
'customer' => [ |
97
|
|
|
'id' => $customerId, |
98
|
|
|
'email' => '[email protected]', |
99
|
|
|
'firstName' => 'Noe', |
100
|
|
|
'lastName' => 'Hill', |
101
|
|
|
'salutationId' => $this->getValidSalutationId(), |
102
|
|
|
'title' => 'Doc', |
103
|
|
|
'customerNumber' => 'Test', |
104
|
|
|
'guest' => true, |
105
|
|
|
'group' => ['name' => 'testse2323'], |
106
|
|
|
'defaultPaymentMethodId' => $this->getValidPaymentMethodId(), |
107
|
|
|
'salesChannelId' => Defaults::SALES_CHANNEL, |
108
|
|
|
'defaultBillingAddressId' => $addressId, |
109
|
|
|
'defaultShippingAddressId' => $addressId, |
110
|
|
|
'addresses' => [ |
111
|
|
|
[ |
112
|
|
|
'id' => $addressId, |
113
|
|
|
'salutationId' => $this->getValidSalutationId(), |
114
|
|
|
'firstName' => 'Floy', |
115
|
|
|
'lastName' => 'Glover', |
116
|
|
|
'zipcode' => '59438-0403', |
117
|
|
|
'city' => 'Stellaberg', |
118
|
|
|
'street' => 'street', |
119
|
|
|
'countryStateId' => $countryStateId, |
120
|
|
|
'country' => [ |
121
|
|
|
'name' => 'kasachstan', |
122
|
|
|
'id' => $this->getValidCountryId(), |
123
|
|
|
'states' => [ |
124
|
|
|
[ |
125
|
|
|
'id' => $countryStateId, |
126
|
|
|
'name' => 'oklahoma', |
127
|
|
|
'shortCode' => 'OH', |
128
|
|
|
], |
129
|
|
|
], |
130
|
|
|
], |
131
|
|
|
], |
132
|
|
|
], |
133
|
|
|
], |
134
|
|
|
], |
135
|
|
|
'billingAddressId' => $addressId, |
136
|
|
|
'addresses' => [ |
137
|
|
|
[ |
138
|
|
|
'salutationId' => $this->getValidSalutationId(), |
139
|
|
|
'firstName' => 'Floy', |
140
|
|
|
'lastName' => 'Glover', |
141
|
|
|
'zipcode' => '59438-0403', |
142
|
|
|
'city' => 'Stellaberg', |
143
|
|
|
'street' => 'street', |
144
|
|
|
'countryId' => $this->getValidCountryId(), |
145
|
|
|
'id' => $addressId, |
146
|
|
|
], |
147
|
|
|
], |
148
|
|
|
], |
149
|
|
|
]; |
150
|
|
|
|
151
|
|
|
return $order; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|