split generic exception

This commit is contained in:
Daniel Seifert 2025-01-08 15:29:20 +01:00
bovenliggende 52adc473ce
commit ca7c96766f
19 gewijzigde bestanden met toevoegingen van 194 en 131 verwijderingen

Bestand weergeven

@ -19,8 +19,9 @@ namespace D3\KlicktippPhpClient;
use Assert\Assert;
use Composer\InstalledVersions;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\NoCredentialsException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Cookie\CookieJar;
@ -28,7 +29,6 @@ use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\ResponseInterface;
use RuntimeException;
class Connection
{
@ -102,8 +102,10 @@ class Connection
* @param string $method
* @param string $uri
* @param array $options
*
* @return ResponseInterface
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function request(string $method, string $uri, array $options = []): ResponseInterface
{
@ -121,22 +123,24 @@ class Connection
$this->parseResponse($e->getResponse());
}
throw new BaseException(
throw new CommunicationException(
$e->getResponse()->getBody(),
$e->getResponse()->getStatusCode(),
$e
);
} catch (GuzzleException $e) {
throw new BaseException($e->getMessage(), $e->getCode(), $e);
throw new CommunicationException($e->getMessage(), $e->getCode(), $e);
}
}
/**
* @param string $method
* @param string $uri
* @param array $options
* @param array $options
*
* @return array
* @throws BaseException
* @throws ResponseContentException
* @throws CommunicationException
*/
public function requestAndParse(string $method, string $uri, array $options = []): array
{
@ -145,38 +149,30 @@ class Connection
/**
* @param ResponseInterface $response
*
* @return array Parsed JSON result
* @throws BaseException
* @throws ResponseContentException
*/
public function parseResponse(ResponseInterface $response): array
{
try {
// Rewind the response (middlewares might have read it already)
$response->getBody()->rewind();
// Rewind the response (middlewares might have read it already)
$response->getBody()->rewind();
$response_body = $response->getBody()->getContents();
$response_body = $response->getBody()->getContents();
$result_array = json_decode($response_body, true);
$result_array = json_decode($response_body, true);
if ($response->getStatusCode() === 204) {
return [];
}
if (! is_array($result_array)) {
throw new BaseException(
sprintf('%s: %s', $response->getStatusCode(), $response_body),
$response->getStatusCode()
);
}
return $result_array;
} catch (RuntimeException $e) {
throw new BaseException(
$e->getMessage(),
0,
$e
);
if ($response->getStatusCode() === 204) {
return [];
}
Assert::lazy()
->setExceptionClass(ResponseContentException::class)
->that($result_array)
->isArray(sprintf('%s: %s', $response->getStatusCode(), $response_body))
->verifyNow();
return $result_array;
}
public function getCookiesJar(): CookieJar

Bestand weergeven

@ -17,7 +17,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\InvalidCredentialTypeException;
use D3\KlicktippPhpClient\Resources\Account as AccountEndpoint;
use Doctrine\Common\Collections\ArrayCollection;
@ -192,7 +192,7 @@ class Account extends Entity
/**
* @return null|bool
* @throws BaseException
* @throws CommunicationException
*/
public function persist(): ?bool
{

Bestand weergeven

@ -17,7 +17,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Field as FieldEndpoint;
class Field extends Entity
@ -49,7 +49,7 @@ class Field extends Entity
/**
* @return null|bool
* @throws BaseException
* @throws CommunicationException
*/
public function persist(): ?bool
{

Bestand weergeven

@ -17,7 +17,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Subscriber as SubscriberEndpoint;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
@ -313,7 +313,7 @@ class Subscriber extends Entity
/**
* @return null|bool
* @throws BaseException
* @throws CommunicationException
*/
public function persist(): ?bool
{
@ -330,7 +330,7 @@ class Subscriber extends Entity
}
/**
* @throws BaseException
* @throws CommunicationException
*/
protected function persistTags(): void
{

Bestand weergeven

@ -17,9 +17,8 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
use Doctrine\Common\Collections\ArrayCollection;
class Subscription extends Entity
{
@ -78,7 +77,7 @@ class Subscription extends Entity
/**
* @return null|bool
* @throws BaseException
* @throws CommunicationException
*/
public function persist(): ?bool
{

Bestand weergeven

@ -17,7 +17,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Entities;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Tag as TagEndpoint;
class Tag extends Entity
@ -61,7 +61,7 @@ class Tag extends Entity
/**
* @return null|bool
* @throws BaseException
* @throws CommunicationException
*/
public function persist(): ?bool
{

Bestand weergeven

@ -19,7 +19,7 @@ namespace D3\KlicktippPhpClient\Exceptions;
use Exception;
class BaseException extends Exception implements KlicktippExceptionInterface
class CommunicationException extends Exception implements KlicktippExceptionInterface
{
public function __construct($message = "", $code = 0, Exception $previous = null)
{

Bestand weergeven

@ -0,0 +1,24 @@
<?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
*/
declare(strict_types=1);
namespace D3\KlicktippPhpClient\Exceptions;
use Assert\LazyAssertionException;
class ResponseContentException extends LazyAssertionException implements KlicktippExceptionInterface
{
}

Bestand weergeven

@ -17,7 +17,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Account;
use D3\KlicktippPhpClient\Resources\Field;
use D3\KlicktippPhpClient\Resources\Subscriber;
@ -30,7 +30,7 @@ class Klicktipp
protected ?Connection $connection = null;
/**
* @throws BaseException
* @throws CommunicationException
*/
public function __construct(
protected string $client_key,

Bestand weergeven

@ -18,7 +18,8 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Account as AccountEntity;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
class Account extends Model
@ -58,7 +59,8 @@ class Account extends Model
public const PASSWORD = 'password';
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function login(): array
{
@ -75,7 +77,8 @@ class Account extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function logout(): bool
{
@ -88,7 +91,8 @@ class Account extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(): array
{
@ -99,7 +103,7 @@ class Account extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function getEntity(): AccountEntity
{
@ -107,7 +111,8 @@ class Account extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(): bool
{

Bestand weergeven

@ -19,7 +19,8 @@ namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Field as FieldEntity;
use D3\KlicktippPhpClient\Entities\FieldList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
class Field extends Model
@ -28,7 +29,8 @@ class Field extends Model
public const NAME = 'name';
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function index(): FieldList
{
@ -41,7 +43,8 @@ class Field extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(string $fieldId): array
{
@ -52,7 +55,7 @@ class Field extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function getEntity(string $fieldId): FieldEntity
{
@ -61,7 +64,8 @@ class Field extends Model
/**
* @return string - new field id
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function create(string $name): string
{
@ -79,7 +83,8 @@ class Field extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(string $fieldId, ?string $name = null): bool
{
@ -97,7 +102,8 @@ class Field extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function delete(string $fieldId): bool
{

Bestand weergeven

@ -19,7 +19,8 @@ namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity;
use D3\KlicktippPhpClient\Entities\SubscriberList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
class Subscriber extends Model
@ -77,7 +78,8 @@ class Subscriber extends Model
public const PARAM_APIKEY = 'apikey';
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function index(): SubscriberList
{
@ -90,7 +92,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(string $subscriberId): array
{
@ -101,7 +104,7 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function getEntity(string $subscriberId): SubscriberEntity
{
@ -109,7 +112,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function search(string $mailAddress): string
{
@ -127,7 +131,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function subscribe(
string $mailAddress,
@ -158,7 +163,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function unsubscribe(string $mailAddress): bool
{
@ -177,7 +183,9 @@ class Subscriber extends Model
/**
* add tag
* @throws BaseException
*
* @throws CommunicationException
* @throws ResponseContentException
*/
public function tag(string $mailAddress, array $tagIds): bool
{
@ -201,7 +209,9 @@ class Subscriber extends Model
/**
* remove tag
* @throws BaseException
*
* @throws CommunicationException
* @throws ResponseContentException
*/
public function untag(string $mailAddress, string $tagId): bool
{
@ -220,7 +230,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function tagged(string $tagId): SubscriberList
{
@ -238,7 +249,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(
string $subscriberId,
@ -266,8 +278,9 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @return true
* @throws CommunicationException
* @throws ResponseContentException
*/
public function delete(string $subscriberId): bool
{
@ -280,7 +293,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function signin(
string $apikey,
@ -309,7 +323,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function signout(string $apikey, string $emailAddress): string
{
@ -328,7 +343,8 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function signoff(string $apikey, string $emailAddress): bool
{
@ -347,7 +363,7 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function setSubscriber(
string $mailAddress,
@ -358,7 +374,7 @@ class Subscriber extends Model
try {
$id = $this->search($mailAddress);
$this->update($id, $fields, $newMailAddress ?? $mailAddress, $smsNumber);
} catch (BaseException) {
} catch (CommunicationException) {
$id = $this->subscribe($newMailAddress ?? $mailAddress, null, null, $fields, $smsNumber);
}
@ -366,7 +382,7 @@ class Subscriber extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function getSubscriberByMailAddress(string $mailAddress): SubscriberEntity
{

Bestand weergeven

@ -19,7 +19,8 @@ namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Subscription as SubscriptionEntity;
use D3\KlicktippPhpClient\Entities\SubscriptionList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
class SubscriptionProcess extends Model
@ -34,7 +35,8 @@ class SubscriptionProcess extends Model
public const PARAM_EMAIL = 'email';
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function index(): SubscriptionList
{
@ -47,7 +49,8 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(string $listId): array
{
@ -58,7 +61,7 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
*/
public function getEntity(string $listId): SubscriptionEntity
{
@ -66,7 +69,8 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function create(?string $name): SubscriptionEntity
{
@ -84,7 +88,8 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(string $listId, ?string $name): bool
{
@ -102,7 +107,8 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function redirect(string $listId, string $email): string
{
@ -121,7 +127,8 @@ class SubscriptionProcess extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function delete(string $listId): bool
{

Bestand weergeven

@ -19,7 +19,8 @@ namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Tag as TagEntity;
use D3\KlicktippPhpClient\Entities\TagList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
class Tag extends Model
@ -29,7 +30,8 @@ class Tag extends Model
public const TEXT = 'text';
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function index(): TagList
{
@ -42,7 +44,8 @@ class Tag extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(string $tagId): array
{
@ -53,7 +56,8 @@ class Tag extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function getEntity(string $tagId): TagEntity
{
@ -62,7 +66,8 @@ class Tag extends Model
/**
* @return string - new tag id
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function create(string $name): string
{
@ -80,7 +85,8 @@ class Tag extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(string $tagId, ?string $name = null, ?string $text = null): bool
{
@ -99,7 +105,8 @@ class Tag extends Model
}
/**
* @throws BaseException
* @throws CommunicationException
* @throws ResponseContentException
*/
public function delete(string $tagId): bool
{

Bestand weergeven

@ -18,7 +18,7 @@ declare(strict_types=1);
namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Account as AccountEntity;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Account;
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
use Generator;
@ -42,7 +42,7 @@ class AccountTest extends IntegrationTestCase
$sut = new Account($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -116,7 +116,7 @@ class AccountTest extends IntegrationTestCase
$sut = new Account($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -146,7 +146,7 @@ class AccountTest extends IntegrationTestCase
$sut = new Account($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$return = $this->callMethod(
@ -187,7 +187,7 @@ class AccountTest extends IntegrationTestCase
$sut = new Account($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(

Bestand weergeven

@ -19,7 +19,7 @@ namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Field as FieldEntity;
use D3\KlicktippPhpClient\Entities\FieldList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\Field;
use D3\KlicktippPhpClient\Resources\Subscriber;
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
@ -44,7 +44,7 @@ class FieldTest extends IntegrationTestCase
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -109,7 +109,7 @@ class FieldTest extends IntegrationTestCase
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$return = $this->callMethod(
@ -146,7 +146,7 @@ class FieldTest extends IntegrationTestCase
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -177,7 +177,7 @@ class FieldTest extends IntegrationTestCase
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -208,7 +208,7 @@ class FieldTest extends IntegrationTestCase
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(

Bestand weergeven

@ -19,7 +19,8 @@ namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Subscriber as SubscriberEntity;
use D3\KlicktippPhpClient\Entities\SubscriberList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\KlicktippExceptionInterface;
use D3\KlicktippPhpClient\Resources\Subscriber;
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
use Generator;
@ -61,7 +62,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -103,7 +104,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$return = $this->callMethod(
@ -204,7 +205,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -235,7 +236,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -308,7 +309,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -341,7 +342,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -380,7 +381,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -412,7 +413,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$return = $this->callMethod(
@ -449,7 +450,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -487,7 +488,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -517,7 +518,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -556,7 +557,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -588,7 +589,7 @@ class SubscriberTest extends IntegrationTestCase
$sut = new Subscriber($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -628,7 +629,7 @@ class SubscriberTest extends IntegrationTestCase
->onlyMethods(['search', 'update', 'subscribe', 'getEntity'])
->getMock();
$sut->expects($this->once())->method('search')->will(
$foundId ? $this->returnValue($foundId) : $this->throwException(new BaseException())
$foundId ? $this->returnValue($foundId) : $this->throwException(new CommunicationException())
);
$sut->expects($updateInvocations)->method('update')->willReturn(true);
$sut->expects($subscribeInvocations)->method('subscribe')->willReturn('myId');

Bestand weergeven

@ -19,7 +19,7 @@ namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Subscription;
use D3\KlicktippPhpClient\Entities\SubscriptionList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Resources\SubscriptionProcess;
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
use Generator;
@ -43,7 +43,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -80,7 +80,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$return = $this->callMethod(
@ -128,7 +128,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$return = $this->callMethod(
@ -152,7 +152,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -183,7 +183,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -214,7 +214,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(

Bestand weergeven

@ -19,7 +19,9 @@ namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Tag as TagEntity;
use D3\KlicktippPhpClient\Entities\TagList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\KlicktippExceptionInterface;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use D3\KlicktippPhpClient\Resources\Tag;
use D3\KlicktippPhpClient\tests\integration\IntegrationTestCase;
use Generator;
@ -43,7 +45,7 @@ class TagTest extends IntegrationTestCase
$sut = new Tag($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(KlicktippExceptionInterface::class);
}
$this->assertEquals(
@ -80,7 +82,7 @@ class TagTest extends IntegrationTestCase
$sut = new Tag($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$return = $this->callMethod(
@ -119,7 +121,7 @@ class TagTest extends IntegrationTestCase
$sut = new Tag($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -150,7 +152,7 @@ class TagTest extends IntegrationTestCase
$sut = new Tag($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(
@ -181,7 +183,7 @@ class TagTest extends IntegrationTestCase
$sut = new Tag($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
$this->expectException(CommunicationException::class);
}
$this->assertEquals(