You are here

class BasicOperationsProviderTest in Payment 8.2

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

@group Payment

Hierarchy

Expanded class hierarchy of BasicOperationsProviderTest

File

tests/src/Unit/Plugin/Payment/Method/BasicOperationsProviderTest.php, line 17

Namespace

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

  /**
   * The payment method configuration list builder.
   *
   * @var \Drupal\Core\Entity\EntityListBuilderInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $paymentMethodConfigurationListBuilder;

  /**
   * The payment method configuration storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $paymentMethodConfigurationStorage;

  /**
   * The provider under test
   *
   * @var \Drupal\payment\Plugin\Payment\Method\BasicOperationsProvider
   */
  protected $sut;

  /**
   * The redirect destination.
   *
   * @var \Drupal\Core\Routing\RedirectDestinationInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $redirectDestination;

  /**
   * The string translator.
   *
   * @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $stringTranslation;

  /**
   * {@inheritdoc}
   */
  public function setUp() : void {
    $this->paymentMethodConfigurationListBuilder = $this
      ->createMock(EntityListBuilderInterface::class);
    $this->paymentMethodConfigurationStorage = $this
      ->createMock(EntityStorageInterface::class);
    $this->redirectDestination = $this
      ->createMock(RedirectDestinationInterface::class);
    $this->stringTranslation = $this
      ->getStringTranslationStub();
    $this->sut = new BasicOperationsProvider($this->stringTranslation, $this->redirectDestination, $this->paymentMethodConfigurationStorage, $this->paymentMethodConfigurationListBuilder);
  }

  /**
   * @covers ::getPaymentMethodConfiguration
   */
  public function testGetPaymentMethodConfiguration() {
    $entity_id = $this
      ->randomMachineName();
    $plugin_id = 'payment_basic:' . $entity_id;
    $payment_method_configuration = $this
      ->createMock(PaymentMethodConfigurationInterface::class);
    $this->paymentMethodConfigurationStorage
      ->expects($this
      ->once())
      ->method('load')
      ->with($entity_id)
      ->willReturn($payment_method_configuration);
    $method = new \ReflectionMethod($this->sut, 'getPaymentMethodConfiguration');
    $method
      ->setAccessible(TRUE);
    $this
      ->assertEquals($payment_method_configuration, $method
      ->invoke($this->sut, $plugin_id));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BasicOperationsProviderTest::$paymentMethodConfigurationListBuilder protected property The payment method configuration list builder.
BasicOperationsProviderTest::$paymentMethodConfigurationStorage protected property The payment method configuration storage.
BasicOperationsProviderTest::$redirectDestination protected property The redirect destination.
BasicOperationsProviderTest::$stringTranslation protected property The string translator.
BasicOperationsProviderTest::$sut protected property The provider under test
BasicOperationsProviderTest::setUp public function Overrides UnitTestCase::setUp
BasicOperationsProviderTest::testGetPaymentMethodConfiguration public function @covers ::getPaymentMethodConfiguration
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.
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.