add subscriber tests

This commit is contained in:
2024-12-29 23:31:22 +01:00
parent c005d1054c
commit 6c407e895b
4 changed files with 628 additions and 29 deletions

View File

@ -20,6 +20,7 @@ use D3\KlicktippPhpClient\tests\TestCase;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Psr\Http\Message\ResponseInterface;
/**
@ -27,11 +28,16 @@ use Psr\Http\Message\ResponseInterface;
*/
class IntegrationTestCase extends TestCase
{
protected array $historyContainer = [];
public function getConnectionMock(ResponseInterface $response): Connection
{
$mock = new MockHandler([$response]);
$history = Middleware::history($this->historyContainer);
$handlerStack = HandlerStack::create($mock);
$handlerStack->push($history);
$client = new Client(['handler' => $handlerStack]);
$connection = new Connection('userName', 'password');
@ -39,4 +45,9 @@ class IntegrationTestCase extends TestCase
return $connection;
}
protected function getHistoryContainer(): array
{
return $this->historyContainer;
}
}