class PaymentStorageSchemaTest in Payment 8.2
@coversDefaultClass \Drupal\payment\Entity\Payment\PaymentStorageSchema
@group Payment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\payment\Unit\Entity\Payment\PaymentStorageSchemaTest
Expanded class hierarchy of PaymentStorageSchemaTest
File
- tests/
src/ Unit/ Entity/ Payment/ PaymentStorageSchemaTest.php, line 21
Namespace
Drupal\Tests\payment\Unit\Entity\PaymentView source
class PaymentStorageSchemaTest extends UnitTestCase {
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection|\PHPUnit\Framework\MockObject\MockObject
*/
protected $database;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $entityTypeManager;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $entityFieldManager;
/**
* The entity type.
*
* @var \Drupal\Core\Entity\ContentEntityTypeInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $entityType;
/**
* The storage field definitions.
*
* @var \Drupal\Core\Field\FieldDefinitionInterface|\PHPUnit\Framework\MockObject\MockObject[]
*/
protected $fieldStorageDefinitions;
/**
* The storage handler.
*
* @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage|\PHPUnit\Framework\MockObject\MockObject
*/
protected $storage;
/**
* The class under test.
*
* @var \Drupal\payment\Entity\Payment\PaymentStorageSchema
*/
protected $sut;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$entity_type_id_key = $this
->randomMachineName();
$entity_type_id = $this
->randomMachineName();
$this->database = $this
->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
$this->fieldStorageDefinitions = array(
$entity_type_id_key => $this
->createMock(FieldDefinitionInterface::class),
);
$this->entityTypeManager = $this
->getMockBuilder(EntityTypeManager::class)
->disableOriginalConstructor()
->getMock();
$this->entityFieldManager = $this
->getMockBuilder(EntityFieldManager::class)
->disableOriginalConstructor()
->getMock();
$this->entityFieldManager
->expects($this
->atLeastOnce())
->method('getActiveFieldStorageDefinitions')
->with($entity_type_id)
->willReturn($this->fieldStorageDefinitions);
$this->entityType = $this
->createMock(ContentEntityTypeInterface::class);
$this->entityType
->expects($this
->atLeastOnce())
->method('id')
->willReturn($entity_type_id);
$this->entityTypeManager
->expects($this
->atLeastOnce())
->method('getActiveDefinition')
->with($entity_type_id)
->willReturn($this->entityType);
$this->storage = $this
->getMockBuilder(SqlContentEntityStorage::class)
->disableOriginalConstructor()
->getMock();
$this->sut = new PaymentStorageSchema($this->entityTypeManager, $this->entityType, $this->storage, $this->database, $this->entityFieldManager);
}
/**
* @covers ::alterEntitySchemaWithNonFieldColumns
*/
public function testAlterEntitySchemaWithNonFieldColumns() {
$schema = array(
'payment' => array(
'fields' => [],
'foreign keys' => [],
),
);
$method = new \ReflectionMethod($this->sut, 'alterEntitySchemaWithNonFieldColumns');
$method
->setAccessible(TRUE);
$method
->invokeArgs($this->sut, array(
&$schema,
));
$this
->assertIsArray($schema);
$this
->assertArrayHasKey('payment', $schema);
$this
->assertIsArray($schema['payment']);
$this
->assertArrayHasKey('fields', $schema['payment']);
foreach ($schema['payment']['fields'] as $field) {
$this
->assertIsArray($field);
$this
->assertArrayHasKey('type', $field);
}
$this
->assertArrayHasKey('foreign keys', $schema['payment']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentStorageSchemaTest:: |
protected | property | The database connection. | |
PaymentStorageSchemaTest:: |
protected | property | The entity field manager. | |
PaymentStorageSchemaTest:: |
protected | property | The entity type. | |
PaymentStorageSchemaTest:: |
protected | property | The entity type manager. | |
PaymentStorageSchemaTest:: |
protected | property | The storage field definitions. | |
PaymentStorageSchemaTest:: |
protected | property | The storage handler. | |
PaymentStorageSchemaTest:: |
protected | property | The class under test. | |
PaymentStorageSchemaTest:: |
public | function |
Overrides UnitTestCase:: |
|
PaymentStorageSchemaTest:: |
public | function | @covers ::alterEntitySchemaWithNonFieldColumns | |
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. |