You are here

public function USPSUnitTestBase::mockShippingMethod in Commerce USPS 8

Mocks a shipping method.

Return value

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

File

tests/src/Unit/USPSUnitTestBase.php, line 155

Class

USPSUnitTestBase
Class USPSUnitTestBase.

Namespace

Drupal\Tests\commerce_usps\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();
}