class EckEntityTest in Entity Construction Kit (ECK) 8
Same name in this branch
- 8 tests/src/Unit/EckEntityTest.php \Drupal\Tests\eck\Unit\EckEntityTest
- 8 tests/src/Kernel/EckEntityTest.php \Drupal\Tests\eck\Kernel\EckEntityTest
- 8 tests/src/Kernel/Plugin/migrate/source/d7/EckEntityTest.php \Drupal\Tests\eck\Kernel\Plugin\migrate\source\d7\EckEntityTest
Tests eck entities.
@group eck
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\eck\Unit\UnitTestBase
- class \Drupal\Tests\eck\Unit\EckEntityTest
- class \Drupal\Tests\eck\Unit\UnitTestBase
Expanded class hierarchy of EckEntityTest
File
- tests/
src/ Unit/ EckEntityTest.php, line 16
Namespace
Drupal\Tests\eck\UnitView source
class EckEntityTest extends UnitTestBase {
/**
* Provides test base field definition data.
*
* @return array
* The test data.
*/
public function baseFieldDefinitionTestDataProvider() {
return [
'default' => [
'config' => [],
'expectedFieldIds' => [
'id',
'uuid',
'langcode',
'type',
],
],
'with title field' => [
'config' => [
'title' => TRUE,
],
'expectedFieldIds' => [
'id',
'uuid',
'langcode',
'type',
'title',
],
],
'with uid field' => [
'config' => [
'uid' => TRUE,
],
'expectedFieldIds' => [
'id',
'uuid',
'langcode',
'type',
'uid',
],
],
'with created field' => [
'config' => [
'created' => TRUE,
],
'expectedFieldIds' => [
'id',
'uuid',
'langcode',
'type',
'created',
],
],
'with changed field' => [
'config' => [
'changed' => TRUE,
],
'expectedFieldIds' => [
'id',
'uuid',
'langcode',
'type',
'changed',
],
],
];
}
/**
* Tests base field definitions.
*
* @param array $config
* The configuration.
* @param array $expectedBaseFieldDefinitionIds
* The expected base field definition ids.
*
* @dataProvider baseFieldDefinitionTestDataProvider
*
* @throws \ReflectionException
*/
public function testBaseFieldDefinitions(array $config, array $expectedBaseFieldDefinitionIds) {
$configs = [
'eck.eck_entity_type.eck_entity_type' => $config,
];
$this
->registerServiceWithContainerMock('config.factory', $this
->getConfigFactoryStub($configs));
$annotationReader = new SimpleAnnotationReader();
$annotationReader
->addNamespace((new \ReflectionClass(Translation::class))
->getNamespaceName());
$annotationReader
->addNamespace((new \ReflectionClass(ConfigEntityType::class))
->getNamespaceName());
$definition = $annotationReader
->getClassAnnotation(new \ReflectionClass(EckEntityType::class), ConfigEntityType::class);
$this
->assertArrayKeysEqual($expectedBaseFieldDefinitionIds, EckEntity::baseFieldDefinitions($definition
->get()));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EckEntityTest:: |
public | function | Provides test base field definition data. | |
EckEntityTest:: |
public | function | Tests base field definitions. | |
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. | |
UnitTestBase:: |
protected | property | The entities. | |
UnitTestBase:: |
private | property | The services. | |
UnitTestBase:: |
protected | function | Adds an entity to the mock storage. | |
UnitTestBase:: |
protected | function | Asserts that the array keys of an array equal the expected keys. | |
UnitTestBase:: |
public | function | Callback for the get method on the mocked service container. | |
UnitTestBase:: |
protected | function | Creates a test entity type. | |
UnitTestBase:: |
protected | function | Creates the language manager mock. | |
UnitTestBase:: |
public | function | Callback for entity storage load multiple. | |
UnitTestBase:: |
private | function | Retrieves the entity manager mock. | |
UnitTestBase:: |
private | function | Retrieves the entity storage mock. | |
UnitTestBase:: |
private | function | Retrieves the entity type manager mock. | |
UnitTestBase:: |
private | function | Retrieves the entity type repository mock. | |
UnitTestBase:: |
private | function | Creates and returns a mocked user. | |
UnitTestBase:: |
private | function | Prepares a mocked service container. | |
UnitTestBase:: |
protected | function | Registers a (mocked) service with the mocked service container. | |
UnitTestBase:: |
protected | function |
Overrides UnitTestCase:: |
1 |
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. |