class PaymentFormTest in Payment 8.2
Same name in this branch
- 8.2 modules/payment_form/tests/src/Unit/Entity/Payment/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Entity\Payment\PaymentFormTest
- 8.2 modules/payment_form/tests/src/Unit/Plugin/Payment/Type/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Payment\Type\PaymentFormTest
- 8.2 modules/payment_form/tests/src/Unit/Plugin/Field/FieldFormatter/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldFormatter\PaymentFormTest
- 8.2 modules/payment_form/tests/src/Unit/Plugin/Field/FieldWidget/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldWidget\PaymentFormTest
- 8.2 modules/payment_form/tests/src/Unit/Plugin/Field/FieldType/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldType\PaymentFormTest
@coversDefaultClass \Drupal\payment_form\Plugin\Field\FieldType\PaymentForm
@group Payment Form Field
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldType\PaymentFormTest
Expanded class hierarchy of PaymentFormTest
File
- modules/
payment_form/ tests/ src/ Unit/ Plugin/ Field/ FieldType/ PaymentFormTest.php, line 17
Namespace
Drupal\Tests\payment_form\Unit\Plugin\Field\FieldTypeView source
class PaymentFormTest extends UnitTestCase {
/**
* The Currency form helper.
*
* @var \Drupal\currency\FormHelperInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $currencyFormHelper;
/**
* The string translator.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $stringTranslation;
/**
* The class under test.
*
* @var \Drupal\payment_form\Plugin\Field\FieldType\PaymentForm|\PHPUnit\Framework\MockObject\MockObject
*/
protected $sut;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$this->currencyFormHelper = $this
->createMock(FormHelperInterface::class);
$this->stringTranslation = $this
->getStringTranslationStub();
$container = new Container();
$container
->set('currency.form_helper', $this->currencyFormHelper);
$container
->set('string_translation', $this->stringTranslation);
\Drupal::setContainer($container);
$this->sut = $this
->getMockBuilder(PaymentForm::class)
->disableOriginalConstructor()
->setMethods([
'getSetting',
])
->getMock();
}
/**
* @covers ::fieldSettingsForm
*/
public function testFieldSettingsForm() {
$this->sut
->expects($this
->once())
->method('getSetting')
->with('currency_code');
$form = [];
/** @var \Drupal\Core\Form\FormStateInterface $form_state */
$form_state = $this
->createMock(FormStateInterface::class);
$this
->assertIsArray($this->sut
->fieldSettingsForm($form, $form_state));
}
/**
* @covers ::schema
*/
public function testSchema() {
$field_storage_definition = $this
->createMock(FieldStorageDefinitionInterface::class);
$schema = $this->sut
->schema($field_storage_definition);
$this
->assertIsArray($schema);
$this
->assertArrayHasKey('plugin_configuration', $schema['columns']);
$this
->assertArrayHasKey('plugin_id', $schema['columns']);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentFormTest:: |
protected | property | The Currency form helper. | |
PaymentFormTest:: |
protected | property | The string translator. | |
PaymentFormTest:: |
protected | property | The class under test. | |
PaymentFormTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PaymentFormTest:: |
public | function | @covers ::fieldSettingsForm | |
PaymentFormTest:: |
public | function | @covers ::schema | |
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. |