abstract class PaymentMethodBaseTestBase in Payment 8.2
Provides a base for tests for classes that extend \Drupal\payment\Plugin\Payment\Method\PaymentMethodBase.
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Plugin\Payment\Method\PaymentMethodBaseTestBase
Expanded class hierarchy of PaymentMethodBaseTestBase
File
- tests/
src/ Unit/ Plugin/ Payment/ Method/ PaymentMethodBaseTestBase.php, line 17
Namespace
Drupal\Tests\payment\Unit\Plugin\Payment\MethodView 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
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentMethodBaseTestBase:: |
protected | property | The cache context manager. | |
PaymentMethodBaseTestBase:: |
protected | property | The event dispatcher. | |
PaymentMethodBaseTestBase:: |
protected | property | The module handler. | 2 |
PaymentMethodBaseTestBase:: |
protected | property | The payment status manager. | 1 |
PaymentMethodBaseTestBase:: |
protected | property | The definition of the payment method plugin under test. | |
PaymentMethodBaseTestBase:: |
protected | property | The ID of the payment method plugin under test. | |
PaymentMethodBaseTestBase:: |
protected | property | The token API. | |
PaymentMethodBaseTestBase:: |
public | function |
Overrides UnitTestCase:: |
2 |
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. |