BasicOperationsProviderTest.php in Payment 8.2
File
tests/src/Unit/Plugin/Payment/Method/BasicOperationsProviderTest.php
View source
<?php
namespace Drupal\Tests\payment\Unit\Plugin\Payment\Method;
use Drupal\Core\Entity\EntityListBuilderInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\payment\Entity\PaymentMethodConfigurationInterface;
use Drupal\payment\Plugin\Payment\Method\BasicOperationsProvider;
use Drupal\Tests\UnitTestCase;
class BasicOperationsProviderTest extends UnitTestCase {
protected $paymentMethodConfigurationListBuilder;
protected $paymentMethodConfigurationStorage;
protected $sut;
protected $redirectDestination;
protected $stringTranslation;
public function setUp() : void {
$this->paymentMethodConfigurationListBuilder = $this
->createMock(EntityListBuilderInterface::class);
$this->paymentMethodConfigurationStorage = $this
->createMock(EntityStorageInterface::class);
$this->redirectDestination = $this
->createMock(RedirectDestinationInterface::class);
$this->stringTranslation = $this
->getStringTranslationStub();
$this->sut = new BasicOperationsProvider($this->stringTranslation, $this->redirectDestination, $this->paymentMethodConfigurationStorage, $this->paymentMethodConfigurationListBuilder);
}
public function testGetPaymentMethodConfiguration() {
$entity_id = $this
->randomMachineName();
$plugin_id = 'payment_basic:' . $entity_id;
$payment_method_configuration = $this
->createMock(PaymentMethodConfigurationInterface::class);
$this->paymentMethodConfigurationStorage
->expects($this
->once())
->method('load')
->with($entity_id)
->willReturn($payment_method_configuration);
$method = new \ReflectionMethod($this->sut, 'getPaymentMethodConfiguration');
$method
->setAccessible(TRUE);
$this
->assertEquals($payment_method_configuration, $method
->invoke($this->sut, $plugin_id));
}
}