You are here

public function USPSInternationalRateRequestTest::testGetPackages in Commerce USPS 8

Test package setup.

@covers ::getPackages

File

tests/src/Unit/USPSInternationalRateRequestTest.php, line 121

Class

USPSInternationalRateRequestTest
Class USPSInternationalRateRequestTest.

Namespace

Drupal\Tests\commerce_usps\Unit

Code

public function testGetPackages() {
  $shipment = $this
    ->mockShipment([
    'unit' => 'lb',
  ], [
    'unit' => 'in',
  ], FALSE);
  $this->rateRequest
    ->setShipment($shipment);
  $packages = $this->rateRequest
    ->getPackages();

  // TODO: Support multiple packages.

  /** @var \USPS\RatePackage $package */
  $package = reset($packages);
  $info = $package
    ->getPackageInfo();
  $this
    ->assertEquals(28806, $info['OriginZip']);
  $this
    ->assertEquals('Great Britain and Northern Ireland', $info['Country']);
  $this
    ->assertEquals(10, $info['Pounds']);
  $this
    ->assertEquals(0, $info['Ounces']);
  $this
    ->assertEquals('RECTANGULAR', $info['Container']);
  $this
    ->assertEquals('REGULAR', $info['Size']);
  $this
    ->assertEquals(3, $info['Width']);
  $this
    ->assertEquals(10, $info['Length']);
  $this
    ->assertEquals(10, $info['Height']);
  $this
    ->assertEquals(0, $info['Girth']);
  $this
    ->assertEquals("True", $info['Machinable']);
}