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
stringThe connection name to use for this fixture.
-
$created public
arrayA list of connections this fixtures has been added to.
-
$records public
arrayThe records to insert.
-
$schema public
arrayThe Elastic search type mapping definition for this type.
-
$table public
stringFull 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\Exceptionon invalid datasource usage.
connection() ¶ public
connection(): string
Get the connection name this fixture should be inserted into.
Returns
stringcreate() ¶ public
create(Cake\Datasource\ConnectionInterface $db): void
Create index and mapping for the type.
Parameters
-
Cake\Datasource\ConnectionInterface$db The Elasticsearch connection
Returns
voidcreateConstraints() ¶ 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
voiddrop() ¶ public
drop(Cake\Datasource\ConnectionInterface $db): void
Drops the index
Parameters
-
Cake\Datasource\ConnectionInterface$db The Elasticsearch connection
Returns
voiddropConstraints() ¶ 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
voidgetIndex() ¶ public
getIndex(): Cake\ElasticSearch\Index
Return the index class from table name
Returns
Cake\ElasticSearch\Indexinsert() ¶ 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
voidsourceName() ¶ public
sourceName(): string
Get the table/collection name for this fixture.
Returns
stringtruncate() ¶ public
truncate(Cake\Datasource\ConnectionInterface $db): void
Truncate the fixture type.
Parameters
-
Cake\Datasource\ConnectionInterface$db The Elasticsearch connection
Returns
voidProperty 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