DatabaseStub
extends Connection
in package
A stub of the Drupal's default Connection class.
@package TestHelpers\DrupalServiceStubs
Table of Contents
Properties
- $pdoMock : MockObject
- The static storage for execute functions.
- $stubExecuteHandlers : array<string|int, mixed>
- The static storage for execute functions.
Methods
- __construct() : mixed
- Constructs a new object.
- delete() : mixed
- {@inheritdoc}
- insert() : mixed
- {@inheritdoc}
- popTransaction() : mixed
- A stub of original function to do nothing.
- select() : mixed
- {@inheritdoc}
- startTransaction() : mixed
- A stub of original function to do nothing.
- stubSetExecuteHandler() : mixed
- Sets the function to handle execute calls.
- mockExecuteForMethod() : MockObject
- Mocks the execute function for a method.
Properties
$pdoMock
The static storage for execute functions.
protected
MockObject
$pdoMock
$stubExecuteHandlers
The static storage for execute functions.
protected
array<string|int, mixed>
$stubExecuteHandlers
= []
Methods
__construct()
Constructs a new object.
public
__construct() : mixed
delete()
{@inheritdoc}
public
delete(mixed $table[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $table : mixed
- $options : array<string|int, mixed> = []
insert()
{@inheritdoc}
public
insert(mixed $table[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $table : mixed
- $options : array<string|int, mixed> = []
popTransaction()
A stub of original function to do nothing.
public
popTransaction(mixed $name) : mixed
Parameters
- $name : mixed
select()
{@inheritdoc}
public
select(mixed $table[, mixed $alias = NULL ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $table : mixed
- $alias : mixed = NULL
- $options : array<string|int, mixed> = []
startTransaction()
A stub of original function to do nothing.
public
startTransaction([mixed $name = '' ]) : mixed
Parameters
- $name : mixed = ''
stubSetExecuteHandler()
Sets the function to handle execute calls.
public
stubSetExecuteHandler(Closure $executeFunction[, string $method = 'all' ]) : mixed
You can call $this->stubExecuteBase()
in your custom callback function
to execute the base stub behavior for the query.
Parameters
- $executeFunction : Closure
-
The execute function.
- $method : string = 'all'
-
The exact method to set (insert, select, delete), all methods by default.
mockExecuteForMethod()
Mocks the execute function for a method.
private
mockExecuteForMethod(string $method, array<string|int, mixed> $methodArguments) : MockObject
Parameters
- $method : string
-
The method name.
- $methodArguments : array<string|int, mixed>
-
The list of arguments of the method.
Return values
MockObject —The mocked method.