1. Go to this page and download the library: Download imdhemy/es-testing-utils library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imdhemy / es-testing-utils example snippets
use Imdhemy\EsUtils\EsMocker;
// Create ES client that returns the mock response
$client = EsMocker::mock(['tagline' => 'You know, for search.'])->build();
use Imdhemy\EsUtils\EsMocker;
// The created client will return the `$info` response with the first request,
// and the `$search` response with the second request, and so on.
// Note: the `thenFail()` method mocks a request exception.
$client = EsMocker::mock($info)->then($index)->then($search)->thenFail($error)->build();
// Or you can directly fail the first request:
$client = EsMocker::fail($message)->build();
use Imdhemy\EsUtils\EsMocker;
$expected=['tagline' => 'You know, for search.'];
$client = EsMocker::mock($expected)->build();
$response = $client->info();
$body = (string) $response->getBody();
$this->assertEquals(json_encode($expected), $body);
use Imdhemy\EsUtils\Faker;
$faker = Faker::create();
$index = $faker->esIndexName(); // Returns a random index name
$createIndex = $faker->esCreateIndex(); // Returns create index response body
// Explore the Faker class to see all the available methods
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.