Drupal Test Helpers module API documentation - release 1.3.1

EntityTypeManagerStub extends EntityTypeManager
in package
implements EntityTypeManagerStubInterface

A stub of the Drupal's default EntityTypeManager class.

@package TestHelpers\DrupalServiceStubs

Tags
phpstan-ignore-next-line

We still need to alter the plugin declaration.

Table of Contents

Interfaces

EntityTypeManagerStubInterface
The EntityTypeManagerStubFactory class.

Properties

$stubEntityStoragesByClass  : array<string|int, mixed>
Static storage for initialized entity storages.

Methods

__construct()  : mixed
{@inheritdoc}
stubGetOrCreateHandler()  : mixed
Creates a new hanlder, or return exists one.
stubGetOrCreateStorage()  : MockObject
Creates a new entity type storage, or return exists one.
stubReset()  : void
Resets the stub and clears all storages.
stubSetDefinition()  : mixed
Sets the definition to stub.

Properties

$stubEntityStoragesByClass

Static storage for initialized entity storages.

protected array<string|int, mixed> $stubEntityStoragesByClass

Methods

__construct()

{@inheritdoc}

public __construct(Traversable $namespaces, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, TranslationInterface $string_translation, ClassResolverInterface $class_resolver, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository) : mixed

No idea about the phpstan warning: Missing cache backend declaration for performance.

Parameters
$namespaces : Traversable
$module_handler : ModuleHandlerInterface
$cache : CacheBackendInterface
$string_translation : TranslationInterface
$class_resolver : ClassResolverInterface
$entity_last_installed_schema_repository : EntityLastInstalledSchemaRepositoryInterface
Tags
todo

Investigate this.

phpstan-ignore-next-line

stubGetOrCreateHandler()

Creates a new hanlder, or return exists one.

public stubGetOrCreateHandler(string $handlerType, string $entityTypeId[, object $handler = NULL ][, mixed $forceOverride = FALSE ]) : mixed
Parameters
$handlerType : string

The handler type.

$entityTypeId : string

The entity type id.

$handler : object = NULL

The hanlder object.

$forceOverride : mixed = FALSE

Forces overriding of already existed one.

Return values
mixed

The handler.

stubGetOrCreateStorage()

Creates a new entity type storage, or return exists one.

public stubGetOrCreateStorage(string $entityClassOrType[, mixed $storageInstance = NULL ][, bool|null $forceOverride = NULL ][, mixed $storageOptions = NULL ]) : MockObject
Parameters
$entityClassOrType : string
$storageInstance : mixed = NULL
$forceOverride : bool|null = NULL

Forces overriding of already existed one.

$storageOptions : mixed = NULL

A list of options to pass to the storage initialization. Acts only once if the storage is not initialized yet.

  • skipPrePostSave: a flag to use direct save on the storage without calling preSave and postSave functions. Can be useful if that functions have dependencies which hard to mock.
  • fields: a list of custom field types to use, like 'integer', 'string', 'entity_reference'. Only core field types are supported.
  • constructorArguments: additional arguments to the constructor.
Return values
MockObject

The mocked Entity Storage Stub.

stubSetDefinition()

Sets the definition to stub.

public stubSetDefinition(string $pluginId[, object $definition = NULL ][, mixed $forceOverride = FALSE ]) : mixed
Parameters
$pluginId : string

The plugin id.

$definition : object = NULL

The definition.

$forceOverride : mixed = FALSE

Forces override of already setted definition.

Return values
mixed

The definition.


        
On this page

Search results