protected function FedExKernelTestBase::setUp in Commerce FedEx 8
Overrides ShippingKernelTestBase::setUp
File
- tests/
src/ Kernel/ FedExKernelTestBase.php, line 74
Class
- FedExKernelTestBase
- Provides a base class for Fedex Kernel tests.
Namespace
Drupal\Tests\commerce_fedex\KernelCode
protected function setUp() : void {
parent::setUp();
$this->store->address = [
'country_code' => 'US',
'postal_code' => '49503',
'locality' => 'Grand Rapids',
'address_line1' => '38 W. Fulton St.',
'administrative_area' => 'MI',
'given_name' => 'Michael',
'family_name' => 'Smith',
];
$this->store
->save();
$this->fedExRequest = $this->container
->get('commerce_fedex.fedex_request');
$this->packerManager = $this->container
->get('commerce_shipping.packer_manager');
$this->shippingMethodManager = $this->container
->get('plugin.manager.commerce_shipping_method');
$this->variations[] = ProductVariation::create([
'type' => 'default',
'sku' => 'test-product-01',
'title' => 'Hat',
'price' => new Price('10', 'USD'),
'weight' => new Weight('500', 'g'),
]);
$this->variations[] = ProductVariation::create([
'type' => 'default',
'sku' => 'test-product-02',
'title' => 'Mug',
'price' => new Price('10', 'USD'),
'weight' => new Weight('300', 'g'),
]);
$this->variations[0]
->save();
$this->variations[1]
->save();
$user = $this
->createUser([
'mail' => $this
->randomString() . '@example.com',
]);
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$this->order = Order::create([
'type' => 'default',
'state' => 'draft',
'mail' => $user
->getEmail(),
'uid' => $user
->id(),
'store_id' => $this->store
->id(),
]);
$this->order
->save();
$this->order = $this
->reloadEntity($this->order);
$order_item[] = OrderItem::create([
'type' => 'default',
'purchased_entity' => $this->variations[0],
'title' => 'Hat',
'quantity' => '2',
'unit_price' => $this->variations[0]
->getPrice(),
]);
$order_item[] = OrderItem::create([
'type' => 'default',
'purchased_entity' => $this->variations[1],
'title' => 'Mug',
'quantity' => '2',
'unit_price' => $this->variations[1]
->getPrice(),
]);
$order_item[0]
->save();
$order_item[1]
->save();
/** @var \Drupal\commerce_order\Entity\OrderItem $order_item */
// $order_item = $this->reloadEntity($order_item);
$this->order
->addItem($order_item[0]);
$this->order
->addItem($order_item[1]);
$this->order
->save();
$this->order = $this
->reloadEntity($this->order);
$this->profile = Profile::create([
'type' => 'customer',
'address' => [
'country_code' => 'US',
'postal_code' => '48823',
'locality' => 'East Lansing',
'address_line1' => '333 Albert',
'administrative_area' => 'MI',
'given_name' => 'Nicholas',
'family_name' => 'Smith',
],
'uid' => $this->order
->getCustomerId(),
]);
$this->profile
->save();
$this->profile = $this
->reloadEntity($this->profile);
}