class PaymentReferenceTest in Payment 8.2
Same name in this branch
- 8.2 modules/payment_reference/tests/src/Unit/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Element/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Element\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Payment/Type/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Payment\Type\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Field/FieldWidget/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldWidget\PaymentReferenceTest
- 8.2 modules/payment_reference/tests/src/Unit/Plugin/Field/FieldType/PaymentReferenceTest.php \Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldType\PaymentReferenceTest
@coversDefaultClass \Drupal\payment_reference\Plugin\Field\FieldType\PaymentReference
@group Payment Reference Field
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldType\PaymentReferenceTest
Expanded class hierarchy of PaymentReferenceTest
File
- modules/
payment_reference/ tests/ src/ Unit/ Plugin/ Field/ FieldType/ PaymentReferenceTest.php, line 19
Namespace
Drupal\Tests\payment_reference\Unit\Plugin\Field\FieldTypeView source
class PaymentReferenceTest extends UnitTestCase {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The payment queue.
*
* @var \Drupal\payment\QueueInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $queue;
/**
* The string translator.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $stringTranslation;
/**
* The class under test.
*
* @var \Drupal\payment_reference\Plugin\Field\FieldType\PaymentReference
*/
protected $sut;
/**
* The field's target_id typed data property.
*
* @var \Drupal\Core\TypedData\TypedDataInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $targetId;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$this->moduleHandler = $this
->createMock(ModuleHandlerInterface::class);
$this->queue = $this
->createMock(QueueInterface::class);
$this->stringTranslation = $this
->getStringTranslationStub();
$this->targetId = $this
->createMock(TypedDataInterface::class);
$container = new ContainerBuilder();
$container
->set('module_handler', $this->moduleHandler);
$container
->set('payment_reference.queue', $this->queue);
$container
->set('string_translation', $this->stringTranslation);
\Drupal::setContainer($container);
$this->sut = $this
->getMockBuilder(PaymentReference::class)
->disableOriginalConstructor()
->setMethods([
'get',
])
->getMock();
$this->sut
->expects($this
->any())
->method('get')
->with('target_id')
->willReturn($this->targetId);
}
/**
* @covers ::defaultStorageSettings
*/
public function testDefaultStorageSettings() {
$settings = $this->sut
->defaultStorageSettings();
$this
->assertIsArray($settings);
}
/**
* @covers ::defaultFieldSettings
*/
public function testDefaultFieldSettings() {
$settings = $this->sut
->defaultFieldSettings();
$this
->assertIsArray($settings);
}
/**
* @covers ::schema
*/
public function testSchema() {
$field_storage_definition = $this
->createMock(FieldStorageDefinitionInterface::class);
$schema = $this->sut
->schema($field_storage_definition);
$this
->assertIsArray($schema);
$this
->arrayHasKey('columns', $schema);
$this
->assertIsArray($schema['columns']);
$this
->arrayHasKey('indexes', $schema);
$this
->assertIsArray($schema['indexes']);
$this
->arrayHasKey('foreign keys', $schema);
$this
->assertIsArray($schema['foreign keys']);
}
/**
* @covers ::storageSettingsForm
*/
public function testStorageSettingsForm() {
$form = [];
$form_state = $this
->createMock(FormStateInterface::class);
$has_data = TRUE;
$this
->assertSame([], $this->sut
->storageSettingsForm($form, $form_state, $has_data));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentReferenceTest:: |
protected | property | The module handler. | |
PaymentReferenceTest:: |
protected | property | The payment queue. | |
PaymentReferenceTest:: |
protected | property | The string translator. | |
PaymentReferenceTest:: |
protected | property | The class under test. | |
PaymentReferenceTest:: |
protected | property | The field's target_id typed data property. | |
PaymentReferenceTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PaymentReferenceTest:: |
public | function | @covers ::defaultFieldSettings | |
PaymentReferenceTest:: |
public | function | @covers ::defaultStorageSettings | |
PaymentReferenceTest:: |
public | function | @covers ::schema | |
PaymentReferenceTest:: |
public | function | @covers ::storageSettingsForm | |
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. |