class ClientManagerTest in Elasticsearch Connector 8.5
Same name and namespace in other branches
- 8.7 tests/src/Unit/ElasticSearch/ClientManagerTest.php \Drupal\Tests\elasticsearch_connector\Unit\ElasticSearch\ClientManagerTest
- 8.6 tests/src/Unit/ElasticSearch/ClientManagerTest.php \Drupal\Tests\elasticsearch_connector\Unit\ElasticSearch\ClientManagerTest
@coversDefaultClass \Drupal\elasticsearch_connector\ElasticSearch\ClientManager
@group elasticsearch_connector
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\elasticsearch_connector\Unit\ElasticSearch\ClientManagerTest
Expanded class hierarchy of ClientManagerTest
File
- tests/
src/ Unit/ ElasticSearch/ ClientManagerTest.php, line 18
Namespace
Drupal\Tests\elasticsearch_connector\Unit\ElasticSearchView source
class ClientManagerTest extends UnitTestCase {
/**
* An instance of ClientManager
*
* @var \Drupal\elasticsearch_connector\ElasticSearch\ClientManager
*/
protected $clientManager;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$module_handler = $this
->prophesize(ModuleHandlerInterface::class);
$client_factory = $this
->prophesize(ClientFactoryInterface::class);
$client_factory
->create(Argument::type('array'))
->willReturn($this
->prophesize(ClientInterface::class)
->reveal());
$this->clientManager = new ClientManager($module_handler
->reveal(), $client_factory
->reveal());
}
/**
* @covers ::__construct
*/
public function testConstruct() {
$this
->assertInstanceOf(ClientManager::class, $this->clientManager);
}
/**
* @covers ::getClientForCluster
*/
public function testGetClientForCluster() {
$cluster = $this
->prophesize(Cluster::class);
$cluster
->getRawUrl()
->willReturn('http://example.com');
$cluster = $cluster
->reveal();
$cluster->options['use_authentication'] = TRUE;
$cluster->options['username'] = 'Tom';
$cluster->options['password'] = 'Waits';
$cluster->options['authentication_type'] = 'basic_auth';
$client = $this->clientManager
->getClientForCluster($cluster);
$this
->assertInstanceOf(ClientInterface::class, $client);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClientManagerTest:: |
protected | property | An instance of ClientManager | |
ClientManagerTest:: |
protected | function |
Overrides UnitTestCase:: |
|
ClientManagerTest:: |
public | function | @covers ::__construct | |
ClientManagerTest:: |
public | function | @covers ::getClientForCluster | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |