2024-12-29 00:49:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view
|
|
|
|
* the LICENSE file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
2025-01-05 15:20:56 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-12-29 00:49:07 +01:00
|
|
|
namespace D3\KlicktippPhpClient\tests\integration;
|
|
|
|
|
|
|
|
use D3\KlicktippPhpClient\Connection;
|
|
|
|
use D3\KlicktippPhpClient\tests\TestCase;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Handler\MockHandler;
|
|
|
|
use GuzzleHttp\HandlerStack;
|
2024-12-29 23:31:22 +01:00
|
|
|
use GuzzleHttp\Middleware;
|
2024-12-29 00:49:07 +01:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @coversNothing
|
|
|
|
*/
|
|
|
|
class IntegrationTestCase extends TestCase
|
|
|
|
{
|
2024-12-29 23:31:22 +01:00
|
|
|
protected array $historyContainer = [];
|
|
|
|
|
2024-12-31 00:27:14 +01:00
|
|
|
public function getConnectionMock(ResponseInterface|array $response): Connection
|
2024-12-29 00:49:07 +01:00
|
|
|
{
|
2024-12-31 00:27:14 +01:00
|
|
|
$mock = new MockHandler(
|
|
|
|
is_array($response) ? $response : [$response]
|
|
|
|
);
|
2024-12-29 00:49:07 +01:00
|
|
|
|
2024-12-29 23:31:22 +01:00
|
|
|
$history = Middleware::history($this->historyContainer);
|
|
|
|
|
2024-12-29 00:49:07 +01:00
|
|
|
$handlerStack = HandlerStack::create($mock);
|
2024-12-29 23:31:22 +01:00
|
|
|
$handlerStack->push($history);
|
2024-12-29 00:49:07 +01:00
|
|
|
$client = new Client(['handler' => $handlerStack]);
|
|
|
|
|
|
|
|
$connection = new Connection('userName', 'password');
|
|
|
|
$connection->setClient($client);
|
|
|
|
|
|
|
|
return $connection;
|
|
|
|
}
|
2024-12-29 23:31:22 +01:00
|
|
|
|
|
|
|
protected function getHistoryContainer(): array
|
|
|
|
{
|
|
|
|
return $this->historyContainer;
|
|
|
|
}
|
2024-12-29 00:49:07 +01:00
|
|
|
}
|