class PackageTypeTest in Commerce Shipping 8.2
Same name in this branch
- 8.2 tests/src/Functional/PackageTypeTest.php \Drupal\Tests\commerce_shipping\Functional\PackageTypeTest
- 8.2 tests/src/Unit/Plugin/Commerce/PackageType/PackageTypeTest.php \Drupal\Tests\commerce_shipping\Unit\Plugin\Commerce\PackageType\PackageTypeTest
@coversDefaultClass \Drupal\commerce_shipping\Plugin\Commerce\PackageType\PackageType @group commerce_shipping
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\commerce_shipping\Unit\Plugin\Commerce\PackageType\PackageTypeTest
Expanded class hierarchy of PackageTypeTest
File
- tests/
src/ Unit/ Plugin/ Commerce/ PackageType/ PackageTypeTest.php, line 14
Namespace
Drupal\Tests\commerce_shipping\Unit\Plugin\Commerce\PackageTypeView source
class PackageTypeTest extends UnitTestCase {
/**
* The test package type.
*
* @var \Drupal\commerce_shipping\Plugin\Commerce\PackageType\PackageType
*/
protected $packageType;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$plugin_definition = [
'id' => 'test id',
'remote_id' => 'test remote id',
'label' => 'test label',
'dimensions' => [
'length' => '1',
'width' => '2',
'height' => '3',
'unit' => 'mm',
],
'weight' => [
'number' => '4',
'unit' => 'kg',
],
];
$this->packageType = new PackageType([], 'test', $plugin_definition);
}
/**
* @covers ::getId
*/
public function testGetId() {
$this
->assertEquals('test id', $this->packageType
->getId());
}
/**
* @covers ::getRemoteId
*/
public function testGetRemoteId() {
$this
->assertEquals('test remote id', $this->packageType
->getRemoteId());
}
/**
* @covers ::getLabel
*/
public function testGetLabel() {
$this
->assertEquals('test label', $this->packageType
->getLabel());
}
/**
* @covers ::getLength
* @covers ::getWidth
* @covers ::getHeight
*/
public function testGetDimensions() {
$this
->assertEquals(new Length('1', 'mm'), $this->packageType
->getLength());
$this
->assertEquals(new Length('2', 'mm'), $this->packageType
->getWidth());
$this
->assertEquals(new Length('3', 'mm'), $this->packageType
->getHeight());
}
/**
* @covers ::getWeight
*/
public function testGetWeight() {
$this
->assertEquals(new Weight('4', 'kg'), $this->packageType
->getWeight());
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PackageTypeTest:: |
protected | property | The test package type. | |
PackageTypeTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PackageTypeTest:: |
public | function | @covers ::getLength @covers ::getWidth @covers ::getHeight | |
PackageTypeTest:: |
public | function | @covers ::getId | |
PackageTypeTest:: |
public | function | @covers ::getLabel | |
PackageTypeTest:: |
public | function | @covers ::getRemoteId | |
PackageTypeTest:: |
public | function | @covers ::getWeight | |
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. |