class UnavailableTest in Payment 8.2
Same name in this branch
- 8.2 tests/src/Unit/Plugin/Payment/Method/UnavailableTest.php \Drupal\Tests\payment\Unit\Plugin\Payment\Method\UnavailableTest
- 8.2 tests/src/Unit/Plugin/Payment/Type/UnavailableTest.php \Drupal\Tests\payment\Unit\Plugin\Payment\Type\UnavailableTest
@coversDefaultClass \Drupal\payment\Plugin\Payment\Method\Unavailable
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Plugin\Payment\Method\UnavailableTest
Expanded class hierarchy of UnavailableTest
File
- tests/
src/ Unit/ Plugin/ Payment/ Method/ UnavailableTest.php, line 18
Namespace
Drupal\Tests\payment\Unit\Plugin\Payment\MethodView source
class UnavailableTest extends UnitTestCase {
/**
* The plugin definition.
*
* @var array
*/
protected $pluginDefinition;
/**
* The payment status manager.
*
* @var \Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $paymentStatusManager;
/**
* The class under test.
*
* @var \Drupal\payment\Plugin\Payment\Method\Unavailable
*/
protected $sut;
/**
* The token utility.
*
* @var \Drupal\Core\Utility\Token
*/
protected $token;
/**
* {@inheritdoc}
*/
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);
}
/**
* @covers ::defaultConfiguration
*/
public function testDefaultConfiguration() {
$this
->assertSame([], $this->sut
->defaultConfiguration());
}
/**
* @covers ::getPluginLabel
*/
public function testGetPluginLabel() {
$this
->assertSame($this->pluginDefinition['label'], $this->sut
->getPluginLabel());
}
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
$this
->assertSame([], $this->sut
->calculateDependencies());
}
/**
* @covers ::getConfiguration
*/
public function testGetConfiguration() {
$this
->assertSame([], $this->sut
->getConfiguration());
}
/**
* @covers ::setConfiguration
*/
public function testSetConfiguration() {
$this
->assertSame($this->sut, $this->sut
->setConfiguration([]));
}
/**
* @covers ::getSupportedCurrencies
*/
public function testGetSupportedCurrencies() {
$method = new \ReflectionMethod($this->sut, 'getSupportedCurrencies');
$method
->setAccessible(TRUE);
$this
->assertSame([], $method
->invoke($this->sut));
}
/**
* @covers ::setPayment
* @covers ::getPayment
*/
public function testGetPayment() {
$payment = $this
->createMock(PaymentInterface::class);
$this
->assertSame($this->sut, $this->sut
->setPayment($payment));
$this
->assertSame($payment, $this->sut
->getPayment());
}
/**
* @covers ::buildConfigurationForm
*/
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);
}
/**
* @covers ::executePaymentAccess
*/
public function testExecutePaymentAccess() {
$account = $this
->createMock(AccountInterface::class);
$this
->assertFalse($this->sut
->executePaymentAccess($account)
->isAllowed());
}
/**
* @covers ::executePayment
*/
public function testExecutePayment() {
$this
->expectException(\RuntimeException::class);
$this->sut
->executePayment();
}
}
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. | |
UnavailableTest:: |
protected | property | The payment status manager. | |
UnavailableTest:: |
protected | property | The plugin definition. | |
UnavailableTest:: |
protected | property | The class under test. | |
UnavailableTest:: |
protected | property | The token utility. | |
UnavailableTest:: |
public | function |
Overrides UnitTestCase:: |
|
UnavailableTest:: |
public | function | @covers ::buildConfigurationForm | |
UnavailableTest:: |
public | function | @covers ::calculateDependencies | |
UnavailableTest:: |
public | function | @covers ::defaultConfiguration | |
UnavailableTest:: |
public | function | @covers ::executePayment | |
UnavailableTest:: |
public | function | @covers ::executePaymentAccess | |
UnavailableTest:: |
public | function | @covers ::getConfiguration | |
UnavailableTest:: |
public | function | @covers ::setPayment @covers ::getPayment | |
UnavailableTest:: |
public | function | @covers ::getPluginLabel | |
UnavailableTest:: |
public | function | @covers ::getSupportedCurrencies | |
UnavailableTest:: |
public | function | @covers ::setConfiguration | |
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. |