UnavailableTest.php in Payment 8.2
File
tests/src/Unit/Plugin/Payment/Method/UnavailableTest.php
View source
<?php
namespace Drupal\Tests\payment\Unit\Plugin\Payment\Method;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Utility\Token;
use Drupal\payment\Entity\PaymentInterface;
use Drupal\payment\Plugin\Payment\Method\Unavailable;
use Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface;
use Drupal\Tests\UnitTestCase;
class UnavailableTest extends UnitTestCase {
protected $pluginDefinition;
protected $paymentStatusManager;
protected $sut;
protected $token;
public function setUp() : void {
parent::setUp();
$this->token = $this
->getMockBuilder(Token::class)
->disableOriginalConstructor()
->getMock();
$this->paymentStatusManager = $this
->createMock(PaymentStatusManagerInterface::class);
$this->pluginDefinition = array(
'label' => $this
->randomMachineName(),
);
$this->sut = new Unavailable([], '', $this->pluginDefinition, $this->token, $this->paymentStatusManager);
}
public function testDefaultConfiguration() {
$this
->assertSame([], $this->sut
->defaultConfiguration());
}
public function testGetPluginLabel() {
$this
->assertSame($this->pluginDefinition['label'], $this->sut
->getPluginLabel());
}
public function testCalculateDependencies() {
$this
->assertSame([], $this->sut
->calculateDependencies());
}
public function testGetConfiguration() {
$this
->assertSame([], $this->sut
->getConfiguration());
}
public function testSetConfiguration() {
$this
->assertSame($this->sut, $this->sut
->setConfiguration([]));
}
public function testGetSupportedCurrencies() {
$method = new \ReflectionMethod($this->sut, 'getSupportedCurrencies');
$method
->setAccessible(TRUE);
$this
->assertSame([], $method
->invoke($this->sut));
}
public function testGetPayment() {
$payment = $this
->createMock(PaymentInterface::class);
$this
->assertSame($this->sut, $this->sut
->setPayment($payment));
$this
->assertSame($payment, $this->sut
->getPayment());
}
public function testBuildConfigurationForm() {
$form = [];
$form_state = $this
->createMock(FormStateInterface::class);
$payment = $this
->createMock(PaymentInterface::class);
$elements = $this->sut
->buildConfigurationForm($form, $form_state, $payment);
$this
->assertIsArray($elements);
$this
->assertEmpty($elements);
}
public function testExecutePaymentAccess() {
$account = $this
->createMock(AccountInterface::class);
$this
->assertFalse($this->sut
->executePaymentAccess($account)
->isAllowed());
}
public function testExecutePayment() {
$this
->expectException(\RuntimeException::class);
$this->sut
->executePayment();
}
}