-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ClientBuilder: setLogger() and setTracer() only accept \Psr\Log\Logge…
…rInterface (#673) This is a more verbose approach than directly adding typehints, but it won't break the projects which may be extending ClientBuilder.
- Loading branch information
1 parent
6d467fa
commit 0270c4f
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Elasticsearch\Tests\ClientBuilder; | ||
|
||
class DummyLogger | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Elasticsearch\Tests; | ||
|
||
use Elasticsearch\ClientBuilder; | ||
use Elasticsearch\Common\Exceptions\InvalidArgumentException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ClientBuilderTest extends TestCase | ||
{ | ||
|
||
public function testClientBuilderThrowsExceptionForIncorrectLoggerClass() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('$logger must implement \Psr\Log\LoggerInterface!'); | ||
|
||
ClientBuilder::create()->setLogger(new \Elasticsearch\Tests\ClientBuilder\DummyLogger()); | ||
} | ||
|
||
public function testClientBuilderThrowsExceptionForIncorrectTracerClass() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('$tracer must implement \Psr\Log\LoggerInterface!'); | ||
|
||
ClientBuilder::create()->setTracer(new \Elasticsearch\Tests\ClientBuilder\DummyLogger()); | ||
} | ||
} |