Improve test coverage, remove dead code.

This commit is contained in:
James Cole
2018-05-20 16:26:27 +02:00
parent c06fd12b07
commit 620c5f515e
18 changed files with 919 additions and 835 deletions

View File

@@ -30,7 +30,7 @@ use Requests;
use Requests_Response;
/**
* Class BunqRequest.
* Class SpectreRequest
*/
abstract class SpectreRequest
{
@@ -47,31 +47,6 @@ abstract class SpectreRequest
/** @var User */
private $user;
/**
* SpectreRequest constructor.
*
* @param User $user
*
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function __construct(User $user)
{
$this->user = $user;
$this->server = 'https://' . config('import.options.spectre.server');
$this->expiresAt = time() + 180;
$privateKey = app('preferences')->get('spectre_private_key', null);
$this->privateKey = $privateKey->data;
// set client ID
$appId = app('preferences')->get('spectre_app_id', null);
$this->appId = $appId->data;
// set service secret
$secret = app('preferences')->get('spectre_secret', null);
$this->secret = $secret->data;
}
/**
*
*/
@@ -125,6 +100,30 @@ abstract class SpectreRequest
$this->privateKey = $privateKey;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
$this->server = 'https://' . config('import.options.spectre.server');
$this->expiresAt = time() + 180;
$privateKey = app('preferences')->getForUser($user, 'spectre_private_key', null);
$this->privateKey = $privateKey->data;
// set client ID
$appId = app('preferences')->getForUser($user, 'spectre_app_id', null);
if (null !== $appId && '' !== (string)$appId->data) {
$this->appId = $appId->data;
}
// set service secret
$secret = app('preferences')->getForUser($user, 'spectre_secret', null);
if (null !== $secret && '' !== (string)$secret->data) {
$this->secret = $secret->data;
}
}
/**
* @param string $method
* @param string $uri