class PaymentAwarePluginFilteredPluginManagerTest in Payment 8.2
@coversDefaultClass \Drupal\payment\Plugin\Payment\PaymentAwarePluginManagerDecorator
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Plugin\Payment\PaymentAwarePluginFilteredPluginManagerTest
Expanded class hierarchy of PaymentAwarePluginFilteredPluginManagerTest
File
- tests/
src/ Unit/ Plugin/ Payment/ PaymentAwarePluginFilteredPluginManagerTest.php, line 17
Namespace
Drupal\Tests\payment\Unit\Plugin\PaymentView source
class PaymentAwarePluginFilteredPluginManagerTest extends UnitTestCase {
/**
* The payment to filter methods by.
*
* @var \Drupal\payment\Entity\PaymentInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $payment;
/**
* The original plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $pluginManager;
/**
* The class under test.
*
* @var \Drupal\payment\Plugin\Payment\PaymentAwarePluginManagerDecorator
*/
protected $sut;
public function setUp() : void {
$this->payment = $this
->createMock(PaymentInterface::class);
$this->pluginManager = $this
->createMock(PluginManagerInterface::class);
$this->sut = new PaymentAwarePluginManagerDecorator($this->payment, $this->pluginManager);
}
/**
* @covers ::createInstance
*/
public function testCreateInstance() {
$plugin_id_a = $this
->randomMachineName();
$plugin_a = $this
->createMock(PluginInspectionInterface::class);
$plugin_id_b = $this
->randomMachineName();
$plugin_b = $this
->createMock(PaymentAwarePluginFilteredPluginManagerUnitTestPaymentAwarePlugin::class);
$plugin_b
->expects($this
->atLeastOnce())
->method('setPayment')
->with($this->payment);
$map = [
[
$plugin_id_a,
[],
$plugin_a,
],
[
$plugin_id_b,
[],
$plugin_b,
],
];
$this->pluginManager
->expects($this
->atLeast(count($map)))
->method('createInstance')
->willReturnMap($map);
$this
->assertSame($plugin_a, $this->sut
->createInstance($plugin_id_a));
$this
->assertSame($plugin_b, $this->sut
->createInstance($plugin_id_b));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentAwarePluginFilteredPluginManagerTest:: |
protected | property | The payment to filter methods by. | |
PaymentAwarePluginFilteredPluginManagerTest:: |
protected | property | The original plugin manager. | |
PaymentAwarePluginFilteredPluginManagerTest:: |
protected | property | The class under test. | |
PaymentAwarePluginFilteredPluginManagerTest:: |
public | function |
Overrides UnitTestCase:: |
|
PaymentAwarePluginFilteredPluginManagerTest:: |
public | function | @covers ::createInstance | |
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. |