You are here

class SupportedCurrencyTest in Payment 8.2

@coversDefaultClass \Drupal\payment\Plugin\Payment\Method\SupportedCurrency

@group Payment

Hierarchy

Expanded class hierarchy of SupportedCurrencyTest

File

tests/src/Unit/Plugin/Payment/Method/SupportedCurrencyTest.php, line 13

Namespace

Drupal\Tests\payment\Unit\Plugin\Payment\Method
View source
class SupportedCurrencyTest extends UnitTestCase {

  /**
   * The currency code.
   *
   * @var string
   */
  protected $currencyCode;

  /**
   * The lowest supported amount.
   *
   * @var int|float
   */
  protected $minimumAmount;

  /**
   * The highest supported amount.
   *
   * @var int|float
   */
  protected $maximumAmount;

  /**
   * The class under test.
   *
   * @var \Drupal\payment\Plugin\Payment\Method\SupportedCurrency
   */
  protected $sut;

  /**
   * {@inheritdoc}
   */
  public function setUp() : void {
    $this->currencyCode = $this
      ->randomMachineName();
    $this->maximumAmount = mt_rand();
    $this->minimumAmount = mt_rand();
    $this->sut = new SupportedCurrency($this->currencyCode, $this->minimumAmount, $this->maximumAmount);
  }

  /**
   * @covers ::getCurrencyCode
   */
  function testGetCurrencyCode() {
    $this
      ->assertSame($this->currencyCode, $this->sut
      ->getCurrencyCode());
  }

  /**
   * @covers ::getMinimumAmount
   */
  function testGetMinimumAmount() {
    $this
      ->assertSame($this->minimumAmount, $this->sut
      ->getMinimumAmount());
  }

  /**
   * @covers ::getMaximumAmount
   */
  function testGetMaximumAmount() {
    $this
      ->assertSame($this->maximumAmount, $this->sut
      ->getMaximumAmount());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
SupportedCurrencyTest::$currencyCode protected property The currency code.
SupportedCurrencyTest::$maximumAmount protected property The highest supported amount.
SupportedCurrencyTest::$minimumAmount protected property The lowest supported amount.
SupportedCurrencyTest::$sut protected property The class under test.
SupportedCurrencyTest::setUp public function Overrides UnitTestCase::setUp
SupportedCurrencyTest::testGetCurrencyCode function @covers ::getCurrencyCode
SupportedCurrencyTest::testGetMaximumAmount function @covers ::getMaximumAmount
SupportedCurrencyTest::testGetMinimumAmount function @covers ::getMinimumAmount
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.