class SymfonyEventDispatcherTest in Payment 8.2
@coversDefaultClass \Drupal\payment\SymfonyEventDispatcher
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\SymfonyEventDispatcherTest
Expanded class hierarchy of SymfonyEventDispatcherTest
File
- tests/
src/ Unit/ SymfonyEventDispatcherTest.php, line 27
Namespace
Drupal\Tests\payment\UnitView source
class SymfonyEventDispatcherTest extends UnitTestCase {
/**
* The Symfony event dispatcher.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $symfonyEventDispatcher;
/**
* The subject under test.
*
* @var \Drupal\payment\SymfonyEventDispatcher
*/
protected $sut;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$this->symfonyEventDispatcher = $this
->createMock(EventDispatcherInterface::class);
$this->sut = new SymfonyEventDispatcher($this->symfonyEventDispatcher);
}
/**
* @covers ::alterQueueLoadedPaymentIds
*/
public function testAlterQueueLoadedPaymentIds() {
$queue_id = $this
->randomMachineName();
$category_id = $this
->randomMachineName();
$owner_id = mt_rand();
$payment_ids = [
mt_rand(),
mt_rand(),
mt_rand(),
];
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_QUEUE_PAYMENT_IDS_ALTER, $this
->isInstanceOf(PaymentQueuePaymentIdsAlter::class));
$this
->assertSame($payment_ids, $this->sut
->alterQueueLoadedPaymentIds($queue_id, $category_id, $owner_id, $payment_ids));
}
/**
* @covers ::setPaymentStatus
*/
public function testSetPaymentStatus() {
$payment = $this
->createMock(PaymentInterface::class);
$previous_payment_status = $this
->createMock(PaymentStatusInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_STATUS_SET, $this
->isInstanceOf(PaymentStatusSet::class));
$this->sut
->setPaymentStatus($payment, $previous_payment_status);
}
/**
* @covers ::preExecutePayment
*
*/
public function testPreExecutePayment() {
$payment = $this
->createMock(PaymentInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_PRE_EXECUTE, $this
->isInstanceOf(PaymentPreExecute::class));
$this->sut
->preExecutePayment($payment);
}
/**
* @covers ::executePaymentAccess
*/
public function testExecutePaymentAccess() {
$payment = $this
->createMock(PaymentInterface::class);
$payment_method = $this
->createMock(PaymentMethodInterface::class);
$account = $this
->createMock(AccountInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_EXECUTE_ACCESS, $this
->isInstanceOf(PaymentExecuteAccess::class));
$this
->assertInstanceOf(AccessResultInterface::class, $this->sut
->executePaymentAccess($payment, $payment_method, $account));
}
/**
* @covers ::preCapturePayment
*/
public function testPreCapturePayment() {
$payment = $this
->createMock(PaymentInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_PRE_CAPTURE, $this
->isInstanceOf(PaymentPreCapture::class));
$this->sut
->preCapturePayment($payment);
}
/**
* @covers ::preRefundPayment
*/
public function testPreRefundPayment() {
$payment = $this
->createMock(PaymentInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_PRE_REFUND, $this
->isInstanceOf(PaymentPreRefund::class));
$this->sut
->preRefundPayment($payment);
}
/**
* @covers ::preResumeContext
*/
public function testPreResumeContext() {
$payment = $this
->createMock(PaymentInterface::class);
$this->symfonyEventDispatcher
->expects($this
->once())
->method('dispatch')
->with(PaymentEvents::PAYMENT_TYPE_PRE_RESUME_CONTEXT, $this
->isInstanceOf(PaymentTypePreResumeContext::class));
$this->sut
->preResumeContext($payment);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
SymfonyEventDispatcherTest:: |
protected | property | The subject under test. | |
SymfonyEventDispatcherTest:: |
protected | property | The Symfony event dispatcher. | |
SymfonyEventDispatcherTest:: |
public | function |
Overrides UnitTestCase:: |
|
SymfonyEventDispatcherTest:: |
public | function | @covers ::alterQueueLoadedPaymentIds | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::executePaymentAccess | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::preCapturePayment | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::preExecutePayment | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::preRefundPayment | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::preResumeContext | |
SymfonyEventDispatcherTest:: |
public | function | @covers ::setPaymentStatus | |
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. |