You are here

abstract class PaymentMethodBaseTestBase in Payment 8.2

Provides a base for tests for classes that extend \Drupal\payment\Plugin\Payment\Method\PaymentMethodBase.

Hierarchy

Expanded class hierarchy of PaymentMethodBaseTestBase

File

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

Namespace

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

  /**
   * The cache context manager.
   *
   * @var \Drupal\Core\Cache\Context\CacheContextsManager
   */
  protected $cacheCContextManager;

  /**
   * The event dispatcher.
   *
   * @var \Drupal\payment\EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $eventDispatcher;

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $moduleHandler;

  /**
   * The token API.
   *
   * @var \Drupal\Core\Utility\Token|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $token;

  /**
   * The payment status manager.
   *
   * @var \Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $paymentStatusManager;

  /**
   * The definition of the payment method plugin under test.
   *
   * @var mixed[]
   */
  protected $pluginDefinition = [];

  /**
   * The ID of the payment method plugin under test.
   *
   * @var string
   */
  protected $pluginId;

  /**
   * {@inheritdoc}
   */
  public function setUp() : void {
    parent::setUp();
    $this->eventDispatcher = $this
      ->createMock(EventDispatcherInterface::class);
    $this->moduleHandler = $this
      ->createMock(ModuleHandlerInterface::class);
    $this->paymentStatusManager = $this
      ->createMock(PaymentStatusManagerInterface::class);
    $this->token = $this
      ->getMockBuilder(Token::class)
      ->disableOriginalConstructor()
      ->getMock();
    $this->pluginDefinition = [
      'active' => TRUE,
      'message_text' => $this
        ->randomMachineName(),
      'message_text_format' => $this
        ->randomMachineName(),
    ];
    $this->pluginId = $this
      ->randomMachineName();
    $this->cacheCContextManager = $this
      ->getMockBuilder(CacheContextsManager::class)
      ->disableOriginalConstructor()
      ->getMock();
    $container = new Container();
    $container
      ->set('cache_contexts_manager', $this->cacheCContextManager);
    \Drupal::setContainer($container);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PaymentMethodBaseTestBase::$cacheCContextManager protected property The cache context manager.
PaymentMethodBaseTestBase::$eventDispatcher protected property The event dispatcher.
PaymentMethodBaseTestBase::$moduleHandler protected property The module handler. 2
PaymentMethodBaseTestBase::$paymentStatusManager protected property The payment status manager. 1
PaymentMethodBaseTestBase::$pluginDefinition protected property The definition of the payment method plugin under test.
PaymentMethodBaseTestBase::$pluginId protected property The ID of the payment method plugin under test.
PaymentMethodBaseTestBase::$token protected property The token API.
PaymentMethodBaseTestBase::setUp public function Overrides UnitTestCase::setUp 2
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.