class PaymentReferenceTest in Payment 8.2
Same name in this branch
- 8.2 modules/payment_reference/tests/src/Unit/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Element/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Element\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Payment/Type/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Payment\Type\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Field/FieldWidget/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldWidget\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Field/FieldType/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldType\PaymentReferenceTest
@coversDefaultClass \Drupal\payment_reference\Element\PaymentReference
@group Payment Reference Field
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment_reference\Unit\Element\PaymentReferenceTest
Expanded class hierarchy of PaymentReferenceTest
File
- modules/
payment_reference/ tests/ src/ Unit/ Element/ PaymentReferenceTest.php, line 28
Namespace
Drupal\Tests\payment_reference\Unit\ElementView source
class PaymentReferenceTest extends UnitTestCase {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* The date formatter.
*
* @var \Drupal\Core\Datetime\DateFormatter|\PHPUnit\Framework\MockObject\MockObject
*/
protected $dateFormatter;
/**
* The link generator.
*
* @var \Drupal\Core\Utility\LinkGeneratorInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $linkGenerator;
/**
* The payment method manager.
*
* @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodManagerInterface
*/
protected $paymentMethodManager;
/**
* The payment method type.
*
* @var \Drupal\plugin\PluginType\PluginTypeInterface|\Prophecy\Prophecy\ObjectProphecy
*/
protected $paymentMethodType;
/**
* The payment queue.
*
* @var \Drupal\payment\QueueInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentQueue;
/**
* The payment storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentStorage;
/**
* The plugin selector manager.
*
* @var \Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $pluginSelectorManager;
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $renderer;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack|\PHPUnit\Framework\MockObject\MockObject
*/
protected $requestStack;
/**
* The string translator.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $stringTranslation;
/**
* The class under test.
*
* @var \Drupal\payment_reference\Element\PaymentReference
*/
protected $sut;
/**
* The url generator.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $urlGenerator;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$this->currentUser = $this
->createMock(AccountInterface::class);
$this->dateFormatter = $this
->getMockBuilder(DateFormatter::class)
->disableOriginalConstructor()
->getMock();
$this->linkGenerator = $this
->createMock(LinkGeneratorInterface::class);
$this->paymentMethodManager = $this
->createMock(PaymentMethodManagerInterface::class);
$this->stringTranslation = $this
->getStringTranslationStub();
$this->paymentMethodType = $this
->prophesize(PluginTypeInterface::class);
$this->paymentQueue = $this
->createMock(QueueInterface::class);
$this->paymentStorage = $this
->createMock(EntityStorageInterface::class);
$this->pluginSelectorManager = $this
->createMock(PluginSelectorManagerInterface::class);
$this->renderer = $this
->createMock(RendererInterface::class);
$this->requestStack = $this
->getMockBuilder(RequestStack::class)
->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this
->createMock(UrlGeneratorInterface::class);
$configuration = [];
$plugin_id = $this
->randomMachineName();
$plugin_definition = [];
$this->sut = new PaymentReference($configuration, $plugin_id, $plugin_definition, $this->requestStack, $this->paymentStorage, $this->stringTranslation, $this->dateFormatter, $this->linkGenerator, $this->renderer, $this->currentUser, $this->pluginSelectorManager, $this->paymentMethodType
->reveal(), new Random(), $this->paymentQueue);
}
/**
* @covers ::create
* @covers ::__construct
*/
function testCreate() {
$entity_type_manager = $this
->createMock(EntityTypeManagerInterface::class);
$entity_type_manager
->expects($this
->once())
->method('getStorage')
->with('payment')
->willReturn($this->paymentStorage);
$plugin_type_manager = $this
->prophesize(PluginTypeManagerInterface::class);
$plugin_type_manager
->getPluginType('payment_method')
->willReturn($this->paymentMethodType
->reveal());
$container = $this
->createMock(ContainerInterface::class);
$map = array(
array(
'current_user',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->currentUser,
),
array(
'date.formatter',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->dateFormatter,
),
array(
'entity_type.manager',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$entity_type_manager,
),
array(
'link_generator',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->linkGenerator,
),
array(
'payment_reference.queue',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->paymentQueue,
),
array(
'plugin.manager.plugin.plugin_selector',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->pluginSelectorManager,
),
array(
'plugin.plugin_type_manager',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$plugin_type_manager
->reveal(),
),
array(
'renderer',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->renderer,
),
array(
'request_stack',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->requestStack,
),
array(
'string_translation',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->stringTranslation,
),
);
$container
->expects($this
->any())
->method('get')
->willReturnMap($map);
$configuration = [];
$plugin_id = $this
->randomMachineName();
$plugin_definition = [];
$sut = PaymentReference::create($container, $configuration, $plugin_id, $plugin_definition);
$this
->assertInstanceOf(PaymentReference::class, $sut);
}
/**
* @covers ::getPaymentQueue
*/
public function testGetPaymentQueue() {
$method = new \ReflectionMethod($this->sut, 'getPaymentQueue');
$method
->setAccessible(TRUE);
$this
->assertSame($this->paymentQueue, $method
->invoke($this->sut));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentReferenceTest:: |
protected | property | The current user. | |
PaymentReferenceTest:: |
protected | property | The date formatter. | |
PaymentReferenceTest:: |
protected | property | The link generator. | |
PaymentReferenceTest:: |
protected | property | The payment method manager. | |
PaymentReferenceTest:: |
protected | property | The payment method type. | |
PaymentReferenceTest:: |
protected | property | The payment queue. | |
PaymentReferenceTest:: |
protected | property | The payment storage. | |
PaymentReferenceTest:: |
protected | property | The plugin selector manager. | |
PaymentReferenceTest:: |
protected | property | The renderer. | |
PaymentReferenceTest:: |
protected | property | The request stack. | |
PaymentReferenceTest:: |
protected | property | The string translator. | |
PaymentReferenceTest:: |
protected | property | The class under test. | |
PaymentReferenceTest:: |
protected | property | The url generator. | |
PaymentReferenceTest:: |
public | function |
Overrides UnitTestCase:: |
|
PaymentReferenceTest:: |
function | @covers ::create @covers ::__construct | ||
PaymentReferenceTest:: |
public | function | @covers ::getPaymentQueue | |
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. |