class UPSShipmentTest in Commerce UPS 8.3
Class UPSShipmentTest.
@coversDefaultClass \Drupal\commerce_ups\UPSShipment @group commerce_ups
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\commerce_ups\Unit\UPSUnitTestBase
- class \Drupal\Tests\commerce_ups\Unit\UPSShipmentTest
- class \Drupal\Tests\commerce_ups\Unit\UPSUnitTestBase
Expanded class hierarchy of UPSShipmentTest
File
- tests/
src/ Unit/ UPSShipmentTest.php, line 13
Namespace
Drupal\Tests\commerce_ups\UnitView source
class UPSShipmentTest extends UPSUnitTestBase {
/**
* The UPS shipment object.
*
* @var \Drupal\commerce_ups\UPSShipment
*/
protected $upsShipment;
/**
* Set up requirements for test.
*/
public function setUp() {
parent::setUp();
$this->upsShipment = new UPSShipment();
}
/**
* Test ship from address.
*
* @covers ::setShipFrom
*/
public function testShipFrom() {
$api_shipment = $this->upsShipment
->getShipment($this
->mockShipment(), $this
->mockShippingMethod());
$ship_from = $api_shipment
->getShipFrom()
->getAddress();
$this
->assertEquals('1025 Brevard Rd', $ship_from
->getAddressLine1());
$this
->assertEquals('Asheville', $ship_from
->getCity());
$this
->assertEquals('NC', $ship_from
->getStateProvinceCode());
$this
->assertEquals('28806', $ship_from
->getPostalCode());
$this
->assertEquals('US', $ship_from
->getCountryCode());
}
/**
* Test ship to address.
*
* @covers ::setShipTo
*/
public function testShipTo() {
$api_shipment = $this->upsShipment
->getShipment($this
->mockShipment(), $this
->mockShippingMethod());
$ship_to = $api_shipment
->getShipTo()
->getAddress();
$this
->assertEquals('1025 Brevard Rd', $ship_to
->getAddressLine1());
$this
->assertEquals('Asheville', $ship_to
->getCity());
$this
->assertEquals('NC', $ship_to
->getStateProvinceCode());
$this
->assertEquals('28806', $ship_to
->getPostalCode());
$this
->assertEquals('US', $ship_to
->getCountryCode());
}
/**
* Test set package.
*
* @covers ::setPackage
* @covers ::setDimensions
* @covers ::setWeight
* @covers ::setPackagingType
*/
public function testPackage() {
$api_shipment = $this->upsShipment
->getShipment($this
->mockShipment(), $this
->mockShippingMethod());
$packages = $api_shipment
->getPackages();
$this
->assertCount(1, $packages);
/** @var \Ups\Entity\Package $package */
$package = reset($packages);
$this
->assertEquals(10, $package
->getDimensions()
->getLength());
$this
->assertEquals(3, $package
->getDimensions()
->getWidth());
$this
->assertEquals(10, $package
->getDimensions()
->getHeight());
$this
->assertEquals(10, $package
->getPackageWeight()
->getWeight());
$this
->assertEquals('00', $package
->getPackagingType()
->getCode());
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UPSShipmentTest:: |
protected | property | The UPS shipment object. | |
UPSShipmentTest:: |
public | function |
Set up requirements for test. Overrides UPSUnitTestBase:: |
|
UPSShipmentTest:: |
public | function | Test set package. | |
UPSShipmentTest:: |
public | function | Test ship from address. | |
UPSShipmentTest:: |
public | function | Test ship to address. | |
UPSUnitTestBase:: |
protected | property | A shipping method configuration array. | |
UPSUnitTestBase:: |
public | function | Creates a mock Drupal Commerce shipment entity. | |
UPSUnitTestBase:: |
public | function | Creates a mock Drupal Commerce shipping method. |