class FedExRequestTest in Commerce FedEx 8
Test Class for the Fedex Shipping Plugin.
@coversDefaultClass \Drupal\commerce_fedex\FedExRequest @group commerce_fedex
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\commerce_fedex\Unit\FedExUnitTestBase
- class \Drupal\Tests\commerce_fedex\Unit\FedExRequestTest
- class \Drupal\Tests\commerce_fedex\Unit\FedExUnitTestBase
Expanded class hierarchy of FedExRequestTest
File
- tests/
src/ Unit/ FedExRequestTest.php, line 11
Namespace
Drupal\Tests\commerce_fedex\UnitView source
class FedExRequestTest extends FedExUnitTestBase {
const RATE_SERVICE_SERVICE_ID = 'crs';
const RATE_SERVICE_MAJOR_VERSION = 20;
/**
* A FedExRequest object to test.
*
* @var \Drupal\commerce_fedex\FedExRequest
*/
protected $request;
/**
* A sample configuration to use.
*
* @var array
*/
protected $configuration;
/**
* @covers ::getRateRequest
*/
public function testRateRequest() {
$rate_request = $this->request
->getRateRequest($this->configuration);
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Structs\\RateRequest", $rate_request);
$client_detail = $rate_request
->getClientDetail();
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Structs\\ClientDetail", $client_detail);
$this
->assertEquals('1234567', $client_detail
->getAccountNumber());
$this
->assertEquals('9876543', $client_detail
->getMeterNumber());
$web_authentication_detail = $rate_request
->getWebAuthenticationDetail();
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Structs\\WebAuthenticationDetail", $web_authentication_detail);
$user_credential = $web_authentication_detail
->getUserCredential();
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Structs\\WebAuthenticationCredential", $user_credential);
$this
->assertEquals('testkey', $user_credential
->getKey());
$this
->assertEquals('testpass', $user_credential
->getPassword());
}
/**
* @covers ::getRateService
*/
public function testRateService() {
$rate_service = $this->request
->getRateService($this->configuration);
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Services\\RateService", $rate_service);
/** @var \NicholasCreativeMedia\FedExPHP\Structs\VersionId $version */
$version = $rate_service->version;
$this
->assertInstanceOf("\\NicholasCreativeMedia\\FedExPHP\\Structs\\VersionId", $version);
$this
->assertEquals(static::RATE_SERVICE_SERVICE_ID, $version
->getServiceId());
$this
->assertEquals(static::RATE_SERVICE_MAJOR_VERSION, $version
->getMajor());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FedExRequestTest:: |
protected | property | A sample configuration to use. | |
FedExRequestTest:: |
protected | property | A FedExRequest object to test. | |
FedExRequestTest:: |
constant | |||
FedExRequestTest:: |
constant | |||
FedExRequestTest:: |
public | function | @covers ::getRateRequest | |
FedExRequestTest:: |
public | function | @covers ::getRateService | |
FedExUnitTestBase:: |
protected | function |
Overrides UnitTestCase:: |
|
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. |