You are here

public function UPSUnitTestBase::mockShippingMethod in Commerce UPS 8.3

Creates a mock Drupal Commerce shipping method.

Return value

\Drupal\commerce_shipping\Plugin\Commerce\ShippingMethod\ShippingMethodInterface The mocked shipping method.

4 calls to UPSUnitTestBase::mockShippingMethod()
UPSRateRequestTest::testRateRequest in tests/src/Unit/UPSRateRequestTest.php
Test rate requests return valid rates.
UPSShipmentTest::testPackage in tests/src/Unit/UPSShipmentTest.php
Test set package.
UPSShipmentTest::testShipFrom in tests/src/Unit/UPSShipmentTest.php
Test ship from address.
UPSShipmentTest::testShipTo in tests/src/Unit/UPSShipmentTest.php
Test ship to address.

File

tests/src/Unit/UPSUnitTestBase.php, line 127

Class

UPSUnitTestBase
Class UPSUnitTestBase.

Namespace

Drupal\Tests\commerce_ups\Unit

Code

public function mockShippingMethod() {
  $shipping_method = $this
    ->prophesize(ShippingMethodInterface::class);
  $package_type = $this
    ->prophesize(PackageTypeInterface::class);
  $package_type
    ->getHeight()
    ->willReturn(new Length(10, 'in'));
  $package_type
    ->getLength()
    ->willReturn(new Length(10, 'in'));
  $package_type
    ->getWidth()
    ->willReturn(new Length(3, 'in'));
  $package_type
    ->getWeight()
    ->willReturn(new Weight(10, 'lb'));
  $package_type
    ->getRemoteId()
    ->willReturn('custom');
  $shipping_method
    ->getDefaultPackageType()
    ->willReturn($package_type);
  return $shipping_method
    ->reveal();
}