Class TestFixture
A Test fixture implementation for elastic search.
Lets you seed indexes for testing your application.
Class extension is temporary as fixtures are missing an interface.
Property Summary
-
$connection public
string
The connection name to use for this fixture.
-
$created public
array
A list of connections this fixtures has been added to.
-
$indexSettings public
array
The index settings used to create the underlying index.
-
$records public
array
The records to insert.
-
$schema public
array
The Elastic search type mapping definition for this type.
-
$table public
string
Full Table Name
Method Summary
-
__construct() public
Instantiate the fixture.
-
connection() public
Get the connection name this fixture should be inserted into.
-
create() public
Create index and mapping for the type.
-
createConstraints() public
No-op method needed because of the Fixture interface. Elasticsearch does not deal with foreign key constraints.
-
drop() public
Drops the index
-
dropConstraints() public
No-op method needed because of the Fixture interface. Elasticsearch does not deal with foreign key constraints.
-
getIndex() public
Return the index class from table name
-
init() public
Initialize the fixture.
-
insert() public
Insert fixture documents.
-
sourceName() public
Get the table/collection name for this fixture.
-
truncate() public
Truncate the fixture type.
Method Detail
__construct() ¶ public
__construct()
Instantiate the fixture.
Throws
Cake\Core\Exception\Exception
on invalid datasource usage.
connection() ¶ public
connection(): string
Get the connection name this fixture should be inserted into.
Returns
string
create() ¶ public
create(Cake\Datasource\ConnectionInterface $db): bool
Create index and mapping for the type.
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection
Returns
bool
createConstraints() ¶ public
createConstraints(Cake\Datasource\ConnectionInterface $db): void
No-op method needed because of the Fixture interface. Elasticsearch does not deal with foreign key constraints.
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection
Returns
void
drop() ¶ public
drop(Cake\Datasource\ConnectionInterface $db): bool
Drops the index
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection
Returns
bool
dropConstraints() ¶ public
dropConstraints(Cake\Datasource\ConnectionInterface $db): void
No-op method needed because of the Fixture interface. Elasticsearch does not deal with foreign key constraints.
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection connection
Returns
void
getIndex() ¶ public
getIndex(): Cake\ElasticSearch\Index
Return the index class from table name
Returns
Cake\ElasticSearch\Index
insert() ¶ public
insert(Cake\Datasource\ConnectionInterface $db): void
Insert fixture documents.
Should insert all the records into the test database.
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection
Returns
void
sourceName() ¶ public
sourceName(): string
Get the table/collection name for this fixture.
Returns
string
truncate() ¶ public
truncate(Cake\Datasource\ConnectionInterface $db): bool
Truncate the fixture type.
Parameters
-
Cake\Datasource\ConnectionInterface
$db The Elasticsearch connection
Returns
bool
Property Detail
$schema ¶ public
The Elastic search type mapping definition for this type.
The schema defined here should be compatible with Elasticsearch's mapping API and Elastica
Type
array