mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 09:22:33 +00:00
Refactor and rename test code.
This commit is contained in:
@@ -1,276 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* FileConfigurator.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Import\Configuration;
|
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Import\Configuration\File\Initial;
|
|
||||||
use FireflyIII\Support\Import\Configuration\File\Map;
|
|
||||||
use FireflyIII\Support\Import\Configuration\File\Roles;
|
|
||||||
use FireflyIII\Support\Import\Configuration\File\UploadConfig;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* Class FileConfigurator.
|
|
||||||
*/
|
|
||||||
class FileConfigurator
|
|
||||||
{
|
|
||||||
/** @var array */
|
|
||||||
private $defaultConfig
|
|
||||||
= [
|
|
||||||
'stage' => 'initial',
|
|
||||||
'has-headers' => false, // assume
|
|
||||||
'date-format' => 'Ymd', // assume
|
|
||||||
'delimiter' => ',', // assume
|
|
||||||
'import-account' => 0, // none,
|
|
||||||
'specifics' => [], // none
|
|
||||||
'column-count' => 0, // unknown
|
|
||||||
'column-roles' => [], // unknown
|
|
||||||
'column-do-mapping' => [], // not yet set which columns must be mapped
|
|
||||||
'column-mapping-config' => [], // no mapping made yet.
|
|
||||||
'file-type' => 'csv', // assume
|
|
||||||
'has-config-file' => true,
|
|
||||||
'apply-rules' => true,
|
|
||||||
'auto-start' => false,
|
|
||||||
];
|
|
||||||
/** @var ImportJob */
|
|
||||||
private $job;
|
|
||||||
/** @var ImportJobRepositoryInterface */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
// give job default config:
|
|
||||||
/** @var string */
|
|
||||||
private $warning = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FileConfigurator constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
Log::debug('Created FileConfigurator');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store any data from the $data array into the job.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function configureJob(array $data): bool
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
|
||||||
}
|
|
||||||
/** @var ConfigurationInterface $object */
|
|
||||||
$object = app($this->getConfigurationClass());
|
|
||||||
$object->setJob($this->job);
|
|
||||||
$result = $object->storeConfiguration($data);
|
|
||||||
$this->warning = $object->getWarningMessage();
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the data required for the next step in the job configuration.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getNextData(): array
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call getNextData() without a job.');
|
|
||||||
}
|
|
||||||
/** @var ConfigurationInterface $object */
|
|
||||||
$object = app($this->getConfigurationClass());
|
|
||||||
$object->setJob($this->job);
|
|
||||||
|
|
||||||
return $object->getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getNextView(): string
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call getNextView() without a job.');
|
|
||||||
}
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$stage = $config['stage'] ?? 'initial';
|
|
||||||
switch ($stage) {
|
|
||||||
case 'initial': // has nothing, no file upload or anything.
|
|
||||||
return 'import.file.initial';
|
|
||||||
case 'upload-config': // has file, needs file config.
|
|
||||||
return 'import.file.upload-config';
|
|
||||||
case 'roles': // has configured file, needs roles.
|
|
||||||
return 'import.file.roles';
|
|
||||||
case 'map': // has roles, needs mapping.
|
|
||||||
return 'import.file.map';
|
|
||||||
}
|
|
||||||
throw new FireflyException(sprintf('No view for stage "%s"', $stage));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return possible warning to user.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getWarningMessage(): string
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call getWarningMessage() without a job.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function isJobConfigured(): bool
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call isJobConfigured() without a job.');
|
|
||||||
}
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$stage = $config['stage'] ?? 'initial';
|
|
||||||
if ('ready' === $stage) {
|
|
||||||
Log::debug('isJobConfigured returns true');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('isJobConfigured returns false');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job)
|
|
||||||
{
|
|
||||||
Log::debug(sprintf('FileConfigurator::setJob(#%d: %s)', $job->id, $job->key));
|
|
||||||
$this->job = $job;
|
|
||||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($job->user);
|
|
||||||
|
|
||||||
// set number of steps to 100:
|
|
||||||
$extendedStatus = $this->getExtendedStatus();
|
|
||||||
$extendedStatus['steps'] = 6;
|
|
||||||
$extendedStatus['done'] = 0;
|
|
||||||
$this->setExtendedStatus($extendedStatus);
|
|
||||||
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$newConfig = array_merge($this->defaultConfig, $config);
|
|
||||||
$this->repository->setConfiguration($job, $newConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Short hand method.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getConfig(): array
|
|
||||||
{
|
|
||||||
return $this->repository->getConfiguration($this->job);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
private function getConfigurationClass(): string
|
|
||||||
{
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$stage = $config['stage'] ?? 'initial';
|
|
||||||
$class = false;
|
|
||||||
Log::debug(sprintf('Now in getConfigurationClass() for stage "%s"', $stage));
|
|
||||||
|
|
||||||
switch ($stage) {
|
|
||||||
case 'initial': // has nothing, no file upload or anything.
|
|
||||||
$class = Initial::class;
|
|
||||||
break;
|
|
||||||
case 'upload-config': // has file, needs file config.
|
|
||||||
$class = UploadConfig::class;
|
|
||||||
break;
|
|
||||||
case 'roles': // has configured file, needs roles.
|
|
||||||
$class = Roles::class;
|
|
||||||
break;
|
|
||||||
case 'map': // has roles, needs mapping.
|
|
||||||
$class = Map::class;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $class || 0 === \strlen($class)) {
|
|
||||||
throw new FireflyException(sprintf('Cannot handle job stage "%s" in getConfigurationClass().', $stage));
|
|
||||||
}
|
|
||||||
if (!class_exists($class)) {
|
|
||||||
throw new FireflyException(sprintf('Class %s does not exist in getConfigurationClass().', $class)); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
Log::debug(sprintf('Configuration class is "%s"', $class));
|
|
||||||
|
|
||||||
return $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorthand method to return the extended status.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getExtendedStatus(): array
|
|
||||||
{
|
|
||||||
return $this->repository->getExtendedStatus($this->job);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorthand method to set the extended status.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @param array $extended
|
|
||||||
*/
|
|
||||||
private function setExtendedStatus(array $extended): void
|
|
||||||
{
|
|
||||||
$this->repository->setExtendedStatus($this->job, $extended);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,235 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SpectreConfigurator.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Import\Configuration;
|
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Import\Configuration\Spectre\HaveAccounts;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* Class SpectreConfigurator.
|
|
||||||
*/
|
|
||||||
class SpectreConfigurator implements ConfiguratorInterface
|
|
||||||
{
|
|
||||||
/** @var ImportJob */
|
|
||||||
private $job;
|
|
||||||
|
|
||||||
/** @var ImportJobRepositoryInterface */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $warning = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ConfiguratorInterface constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store any data from the $data array into the job.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function configureJob(array $data): bool
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
|
||||||
}
|
|
||||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
|
||||||
Log::debug(sprintf('in getNextData(), for stage "%s".', $stage));
|
|
||||||
switch ($stage) {
|
|
||||||
case 'have-accounts':
|
|
||||||
/** @var HaveAccounts $class */
|
|
||||||
$class = app(HaveAccounts::class);
|
|
||||||
$class->setJob($this->job);
|
|
||||||
$class->storeConfiguration($data);
|
|
||||||
|
|
||||||
// update job for next step and set to "configured".
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$config['stage'] = 'have-account-mapping';
|
|
||||||
$this->repository->setConfiguration($this->job, $config);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
throw new FireflyException(sprintf('Cannot store configuration when job is in state "%s"', $stage));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the data required for the next step in the job configuration.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getNextData(): array
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
|
||||||
}
|
|
||||||
$config = $this->getConfig();
|
|
||||||
$stage = $config['stage'] ?? 'initial';
|
|
||||||
|
|
||||||
Log::debug(sprintf('in getNextData(), for stage "%s".', $stage));
|
|
||||||
switch ($stage) {
|
|
||||||
case 'has-token':
|
|
||||||
// simply redirect to Spectre.
|
|
||||||
$config['is-redirected'] = true;
|
|
||||||
$config['stage'] = 'user-logged-in';
|
|
||||||
$status = 'configured';
|
|
||||||
|
|
||||||
// update config and status:
|
|
||||||
$this->repository->setConfiguration($this->job, $config);
|
|
||||||
$this->repository->setStatus($this->job, $status);
|
|
||||||
|
|
||||||
return $this->repository->getConfiguration($this->job);
|
|
||||||
case 'have-accounts':
|
|
||||||
/** @var HaveAccounts $class */
|
|
||||||
$class = app(HaveAccounts::class);
|
|
||||||
$class->setJob($this->job);
|
|
||||||
|
|
||||||
return $class->getData();
|
|
||||||
default:
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getNextView(): string
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
|
||||||
}
|
|
||||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
|
||||||
Log::debug(sprintf('in getNextView(), for stage "%s".', $stage));
|
|
||||||
switch ($stage) {
|
|
||||||
case 'has-token':
|
|
||||||
// redirect to Spectre.
|
|
||||||
Log::info('User is being redirected to Spectre.');
|
|
||||||
|
|
||||||
return 'import.spectre.redirect';
|
|
||||||
case 'have-accounts':
|
|
||||||
return 'import.spectre.accounts';
|
|
||||||
default:
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return possible warning to user.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getWarningMessage(): string
|
|
||||||
{
|
|
||||||
return $this->warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function isJobConfigured(): bool
|
|
||||||
{
|
|
||||||
if (null === $this->job) {
|
|
||||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
|
||||||
}
|
|
||||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
|
||||||
Log::debug(sprintf('in isJobConfigured(), for stage "%s".', $stage));
|
|
||||||
switch ($stage) {
|
|
||||||
case 'has-token':
|
|
||||||
case 'have-accounts':
|
|
||||||
Log::debug('isJobConfigured returns false');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
Log::debug('isJobConfigured returns true');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job): void
|
|
||||||
{
|
|
||||||
// make repository
|
|
||||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
|
||||||
$this->repository->setUser($job->user);
|
|
||||||
|
|
||||||
// set default config:
|
|
||||||
$defaultConfig = [
|
|
||||||
'has-token' => false,
|
|
||||||
'token' => '',
|
|
||||||
'token-expires' => 0,
|
|
||||||
'token-url' => '',
|
|
||||||
'is-redirected' => false,
|
|
||||||
'customer' => null,
|
|
||||||
'login' => null,
|
|
||||||
'stage' => 'initial',
|
|
||||||
'accounts' => '',
|
|
||||||
'accounts-mapped' => '',
|
|
||||||
'auto-start' => true,
|
|
||||||
'apply-rules' => true,
|
|
||||||
];
|
|
||||||
$currentConfig = $this->repository->getConfiguration($job);
|
|
||||||
$finalConfig = array_merge($defaultConfig, $currentConfig);
|
|
||||||
|
|
||||||
// set default extended status:
|
|
||||||
$extendedStatus = $this->repository->getExtendedStatus($job);
|
|
||||||
$extendedStatus['steps'] = 6;
|
|
||||||
|
|
||||||
// save to job:
|
|
||||||
$job = $this->repository->setConfiguration($job, $finalConfig);
|
|
||||||
$job = $this->repository->setExtendedStatus($job, $extendedStatus);
|
|
||||||
$this->job = $job;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorthand method.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getConfig(): array
|
|
||||||
{
|
|
||||||
return $this->repository->getConfiguration($this->job);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -28,11 +28,11 @@ namespace FireflyIII\Import\JobConfiguration;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigurationInterface;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigurationInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\NewFileJobHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -37,8 +37,6 @@ use Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SpectreJobConfiguration
|
* Class SpectreJobConfiguration
|
||||||
*
|
|
||||||
* @package FireflyIII\Import\JobConfiguration
|
|
||||||
*/
|
*/
|
||||||
class SpectreJobConfiguration implements JobConfigurationInterface
|
class SpectreJobConfiguration implements JobConfigurationInterface
|
||||||
{
|
{
|
||||||
|
@@ -46,8 +46,6 @@ use Log;
|
|||||||
* Creates new transactions based upon arrays. Will first check the array for duplicates.
|
* Creates new transactions based upon arrays. Will first check the array for duplicates.
|
||||||
*
|
*
|
||||||
* Class ImportArrayStorage
|
* Class ImportArrayStorage
|
||||||
*
|
|
||||||
* @package FireflyIII\Import\Storage
|
|
||||||
*/
|
*/
|
||||||
class ImportArrayStorage
|
class ImportArrayStorage
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Models\TransactionType;
|
|||||||
/**
|
/**
|
||||||
* Interface TransactionTypeRepositoryInterface
|
* Interface TransactionTypeRepositoryInterface
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Repositories\TransactionType
|
|
||||||
*/
|
*/
|
||||||
interface TransactionTypeRepositoryInterface
|
interface TransactionTypeRepositoryInterface
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Services\Github\Request;
|
|||||||
/**
|
/**
|
||||||
* Interface GithubRequest
|
* Interface GithubRequest
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\Github\Request
|
|
||||||
*/
|
*/
|
||||||
interface GithubRequest
|
interface GithubRequest
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Services\IP;
|
|||||||
/**
|
/**
|
||||||
* Interface IPRetrievalInterface
|
* Interface IPRetrievalInterface
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\IP
|
|
||||||
*/
|
*/
|
||||||
interface IPRetrievalInterface
|
interface IPRetrievalInterface
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,6 @@ use Validator;
|
|||||||
/**
|
/**
|
||||||
* Trait AccountServiceTrait
|
* Trait AccountServiceTrait
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\Internal\Support
|
|
||||||
*/
|
*/
|
||||||
trait AccountServiceTrait
|
trait AccountServiceTrait
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,6 @@ use Illuminate\Support\Collection;
|
|||||||
/**
|
/**
|
||||||
* Trait BillServiceTrait
|
* Trait BillServiceTrait
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\Internal\Support
|
|
||||||
*/
|
*/
|
||||||
trait BillServiceTrait
|
trait BillServiceTrait
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,6 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
/**
|
/**
|
||||||
* Trait JournalServiceTrait
|
* Trait JournalServiceTrait
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\Internal\Support
|
|
||||||
*/
|
*/
|
||||||
trait JournalServiceTrait
|
trait JournalServiceTrait
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Trait TransactionServiceTrait
|
* Trait TransactionServiceTrait
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Services\Internal\Support
|
|
||||||
*/
|
*/
|
||||||
trait TransactionServiceTrait
|
trait TransactionServiceTrait
|
||||||
{
|
{
|
||||||
|
@@ -1,174 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* HaveAccounts.php
|
|
||||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\Bunq;
|
|
||||||
|
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\AccountType;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @deprecated
|
|
||||||
* Class HaveAccounts
|
|
||||||
*/
|
|
||||||
class HaveAccounts
|
|
||||||
{
|
|
||||||
/** @var ImportJob */
|
|
||||||
private $job;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data necessary to show the configuration screen.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getData(): array
|
|
||||||
{
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
|
||||||
/** @var CurrencyRepositoryInterface $currencyRepository */
|
|
||||||
$currencyRepository = app(CurrencyRepositoryInterface::class);
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$collection = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
|
||||||
$dbAccounts = [];
|
|
||||||
/** @var Account $dbAccount */
|
|
||||||
foreach ($collection as $dbAccount) {
|
|
||||||
$id = $dbAccount->id;
|
|
||||||
$currencyId = (int)$accountRepository->getMetaValue($dbAccount, 'currency_id');
|
|
||||||
$currency = $currencyRepository->findNull($currencyId);
|
|
||||||
$dbAccounts[$id] = [
|
|
||||||
'account' => $dbAccount,
|
|
||||||
'currency' => $currency ?? $defaultCurrency,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop Bunq accounts:
|
|
||||||
/**
|
|
||||||
* @var int $index
|
|
||||||
* @var array $bunqAccount
|
|
||||||
*/
|
|
||||||
foreach ($config['accounts'] as $index => $bunqAccount) {
|
|
||||||
// find accounts with currency code
|
|
||||||
$code = $bunqAccount['currency'];
|
|
||||||
$selection = $this->filterAccounts($dbAccounts, $code);
|
|
||||||
$config['accounts'][$index]['iban'] = $this->getIban($bunqAccount);
|
|
||||||
$config['accounts'][$index]['options'] = $selection;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'config' => $config,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return possible warning to user.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getWarningMessage(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*
|
|
||||||
* @return ConfigurationInterface
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job)
|
|
||||||
{
|
|
||||||
$this->job = $job;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the result.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function storeConfiguration(array $data): bool
|
|
||||||
{
|
|
||||||
$accounts = $data['bunq_account_id'] ?? [];
|
|
||||||
$mapping = [];
|
|
||||||
foreach ($accounts as $bunqId) {
|
|
||||||
$bunqId = (int)$bunqId;
|
|
||||||
$doImport = (int)($data['do_import'][$bunqId] ?? 0.0) === 1;
|
|
||||||
$account = (int)($data['import'][$bunqId] ?? 0.0);
|
|
||||||
if ($doImport) {
|
|
||||||
$mapping[$bunqId] = $account;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$config['accounts-mapped'] = $mapping;
|
|
||||||
$this->job->configuration = $config;
|
|
||||||
$this->job->save();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $dbAccounts
|
|
||||||
* @param string $code
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function filterAccounts(array $dbAccounts, string $code): array
|
|
||||||
{
|
|
||||||
$accounts = [];
|
|
||||||
foreach ($dbAccounts as $accountId => $data) {
|
|
||||||
if ($data['currency']->code === $code) {
|
|
||||||
$accounts[$accountId] = [
|
|
||||||
'name' => $data['account']['name'],
|
|
||||||
'iban' => $data['account']['iban'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $accounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $bunqAccount
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getIban(array $bunqAccount): string
|
|
||||||
{
|
|
||||||
$iban = '';
|
|
||||||
if (\is_array($bunqAccount['alias'])) {
|
|
||||||
foreach ($bunqAccount['alias'] as $alias) {
|
|
||||||
if ($alias['type'] === 'IBAN') {
|
|
||||||
$iban = $alias['value'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $iban;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,155 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* HaveAccounts.php
|
|
||||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\Spectre;
|
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\AccountType;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* Class HaveAccounts
|
|
||||||
*/
|
|
||||||
class HaveAccounts
|
|
||||||
{
|
|
||||||
/** @var ImportJob */
|
|
||||||
private $job;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data necessary to show the configuration screen.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getData(): array
|
|
||||||
{
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
|
||||||
/** @var CurrencyRepositoryInterface $currencyRepository */
|
|
||||||
$currencyRepository = app(CurrencyRepositoryInterface::class);
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$collection = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
|
||||||
$dbAccounts = [];
|
|
||||||
/** @var Account $dbAccount */
|
|
||||||
foreach ($collection as $dbAccount) {
|
|
||||||
$id = $dbAccount->id;
|
|
||||||
$currencyId = (int)$dbAccount->getMeta('currency_id');
|
|
||||||
$currency = $currencyRepository->find($currencyId);
|
|
||||||
$dbAccounts[$id] = [
|
|
||||||
'account' => $dbAccount,
|
|
||||||
'currency' => null === $currency->id ? $defaultCurrency : $currency,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop Spectre accounts:
|
|
||||||
/**
|
|
||||||
* @var int $index
|
|
||||||
* @var array $spectreAccount
|
|
||||||
*/
|
|
||||||
foreach ($config['accounts'] as $index => $spectreAccount) {
|
|
||||||
// find accounts with currency code
|
|
||||||
$code = $spectreAccount['currency_code'];
|
|
||||||
$selection = $this->filterAccounts($dbAccounts, $code);
|
|
||||||
$config['accounts'][$index]['options'] = app('expandedform')->makeSelectList($selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return [
|
|
||||||
'config' => $config,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return possible warning to user.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getWarningMessage(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImportJob $job
|
|
||||||
*
|
|
||||||
* @return ConfigurationInterface
|
|
||||||
*/
|
|
||||||
public function setJob(ImportJob $job)
|
|
||||||
{
|
|
||||||
$this->job = $job;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the result.
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function storeConfiguration(array $data): bool
|
|
||||||
{
|
|
||||||
$accounts = $data['spectre_account_id'] ?? [];
|
|
||||||
$mapping = [];
|
|
||||||
foreach ($accounts as $spectreId) {
|
|
||||||
$spectreId = (int)$spectreId;
|
|
||||||
$doImport = (int)($data['do_import'][$spectreId] ?? 0.0) === 1;
|
|
||||||
$account = (int)($data['import'][$spectreId] ?? 0.0);
|
|
||||||
if ($doImport) {
|
|
||||||
$mapping[$spectreId] = $account;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$config = $this->job->configuration;
|
|
||||||
$config['accounts-mapped'] = $mapping;
|
|
||||||
$this->job->configuration = $config;
|
|
||||||
$this->job->save();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $dbAccounts
|
|
||||||
* @param string $code
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
private function filterAccounts(array $dbAccounts, string $code): Collection
|
|
||||||
{
|
|
||||||
$collection = new Collection;
|
|
||||||
foreach ($dbAccounts as $accountId => $data) {
|
|
||||||
if ($data['currency']->code === $code) {
|
|
||||||
$collection->push($data['account']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $collection;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -33,7 +33,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Trait GetSpectreCustomerTrait
|
* Trait GetSpectreCustomerTrait
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Information
|
|
||||||
*/
|
*/
|
||||||
trait GetSpectreCustomerTrait
|
trait GetSpectreCustomerTrait
|
||||||
{
|
{
|
||||||
@@ -52,9 +51,11 @@ trait GetSpectreCustomerTrait
|
|||||||
/** @var NewCustomerRequest $request */
|
/** @var NewCustomerRequest $request */
|
||||||
$request = app(NewCustomerRequest::class);
|
$request = app(NewCustomerRequest::class);
|
||||||
$request->setUser($importJob->user);
|
$request->setUser($importJob->user);
|
||||||
|
// todo what if customer is still null?
|
||||||
$customer = $request->getCustomer();
|
$customer = $request->getCustomer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug('The customer is not null.');
|
Log::debug('The customer is not null.');
|
||||||
|
|
||||||
return $customer;
|
return $customer;
|
||||||
@@ -72,7 +73,7 @@ trait GetSpectreCustomerTrait
|
|||||||
$customer = null;
|
$customer = null;
|
||||||
|
|
||||||
// check users preferences.
|
// check users preferences.
|
||||||
$preference = app('preferences')->getForUser($importJob->user, 'spectre_customer');
|
$preference = app('preferences')->getForUser($importJob->user, 'spectre_customer', null);
|
||||||
if (null !== $preference) {
|
if (null !== $preference) {
|
||||||
Log::debug('Customer is in user configuration');
|
Log::debug('Customer is in user configuration');
|
||||||
$customer = new Customer($preference->data);
|
$customer = new Customer($preference->data);
|
||||||
@@ -96,9 +97,10 @@ trait GetSpectreCustomerTrait
|
|||||||
}
|
}
|
||||||
Log::debug(sprintf('Skip customer with name "%s"', $current->getIdentifier()));
|
Log::debug(sprintf('Skip customer with name "%s"', $current->getIdentifier()));
|
||||||
}
|
}
|
||||||
|
if (null !== $customer) {
|
||||||
// store in preferences.
|
// store in preferences.
|
||||||
app('preferences')->setForUser($importJob->user, 'spectre_customer', $customer->toArray());
|
app('preferences')->setForUser($importJob->user, 'spectre_customer', $customer->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
return $customer;
|
return $customer;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConfigurationInterface.php
|
* ConfigurationInterface.php
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III.
|
* This file is part of Firefly III.
|
||||||
*
|
*
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConfigureUploadHandlerphp
|
* ConfigureUploadHandler.php
|
||||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III.
|
* This file is part of Firefly III.
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@@ -32,8 +32,6 @@ use Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ConfigureUploadHandler
|
* Class ConfigureUploadHandler
|
||||||
*
|
|
||||||
* @package FireflyIII\Support\Import\Configuration\File
|
|
||||||
*/
|
*/
|
||||||
class ConfigureUploadHandler implements ConfigurationInterface
|
class ConfigureUploadHandler implements ConfigurationInterface
|
||||||
{
|
{
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\File;
|
namespace FireflyIII\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -36,8 +36,6 @@ use Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NewFileJobHandler
|
* Class NewFileJobHandler
|
||||||
*
|
|
||||||
* @package FireflyIII\Support\Import\Configuration\File
|
|
||||||
*/
|
*/
|
||||||
class NewFileJobHandler implements ConfigurationInterface
|
class NewFileJobHandler implements ConfigurationInterface
|
||||||
{
|
{
|
@@ -37,7 +37,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class AuthenticateConfig
|
* Class AuthenticateConfig
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
|
||||||
*/
|
*/
|
||||||
class AuthenticateConfig implements SpectreJobConfig
|
class AuthenticateConfig implements SpectreJobConfig
|
||||||
{
|
{
|
||||||
|
@@ -40,7 +40,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class ChooseAccount
|
* Class ChooseAccount
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
|
||||||
*/
|
*/
|
||||||
class ChooseAccount implements SpectreJobConfig
|
class ChooseAccount implements SpectreJobConfig
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class ChooseLoginHandler
|
* Class ChooseLoginHandler
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
|
||||||
*/
|
*/
|
||||||
class ChooseLoginHandler implements SpectreJobConfig
|
class ChooseLoginHandler implements SpectreJobConfig
|
||||||
{
|
{
|
||||||
|
@@ -30,7 +30,6 @@ use Illuminate\Support\MessageBag;
|
|||||||
/**
|
/**
|
||||||
* Class NewConfig
|
* Class NewConfig
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
|
||||||
*/
|
*/
|
||||||
class NewConfig implements SpectreJobConfig
|
class NewConfig implements SpectreJobConfig
|
||||||
{
|
{
|
||||||
|
@@ -30,7 +30,6 @@ use Illuminate\Support\MessageBag;
|
|||||||
/**
|
/**
|
||||||
* Interface SpectreJobConfig
|
* Interface SpectreJobConfig
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
|
||||||
*/
|
*/
|
||||||
interface SpectreJobConfig
|
interface SpectreJobConfig
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,6 @@ use FireflyIII\Models\ImportJob;
|
|||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* Class StageFinalHandler
|
* Class StageFinalHandler
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Routine\Fake
|
|
||||||
*/
|
*/
|
||||||
class StageFinalHandler
|
class StageFinalHandler
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class CSVProcessor
|
* Class CSVProcessor
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Routine\File
|
|
||||||
*/
|
*/
|
||||||
class CSVProcessor implements FileProcessorInterface
|
class CSVProcessor implements FileProcessorInterface
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Models\ImportJob;
|
|||||||
/**
|
/**
|
||||||
* Interface FileProcessorInterface
|
* Interface FileProcessorInterface
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Routine\File
|
|
||||||
*/
|
*/
|
||||||
interface FileProcessorInterface
|
interface FileProcessorInterface
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class StageImportDataHandler
|
* Class StageImportDataHandler
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Routine\Spectre
|
|
||||||
*/
|
*/
|
||||||
class StageImportDataHandler
|
class StageImportDataHandler
|
||||||
{
|
{
|
||||||
|
@@ -34,7 +34,6 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class StageNewHandler
|
* Class StageNewHandler
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Import\Routine\Spectre
|
|
||||||
*/
|
*/
|
||||||
class StageNewHandler
|
class StageNewHandler
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,6 @@ use Illuminate\Contracts\Console\Kernel;
|
|||||||
/**
|
/**
|
||||||
* Trait CreatesApplication
|
* Trait CreatesApplication
|
||||||
*
|
*
|
||||||
* @package Tests
|
|
||||||
*/
|
*/
|
||||||
trait CreatesApplication
|
trait CreatesApplication
|
||||||
{
|
{
|
||||||
|
@@ -27,10 +27,10 @@ namespace Tests\Unit\Import\JobConfiguration;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
||||||
use FireflyIII\Support\Import\Configuration\File\NewFileJobHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Unit\Support\Import\Configuration\File;
|
namespace Tests\Unit\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
@@ -31,7 +31,7 @@ use FireflyIII\Import\Specifics\IngDescription;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
@@ -41,12 +41,11 @@ use Tests\TestCase;
|
|||||||
/**
|
/**
|
||||||
* Class ConfigureMappingHandlerTest
|
* Class ConfigureMappingHandlerTest
|
||||||
*
|
*
|
||||||
* @package Tests\Unit\Support\Import\Configuration\File
|
|
||||||
*/
|
*/
|
||||||
class ConfigureMappingHandlerTest extends TestCase
|
class ConfigureMappingHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testApplySpecifics(): void
|
public function testApplySpecifics(): void
|
||||||
{
|
{
|
||||||
@@ -81,7 +80,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
@@ -145,7 +144,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testDoColumnConfig(): void
|
public function testDoColumnConfig(): void
|
||||||
{
|
{
|
||||||
@@ -208,7 +207,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testDoMapOfColumn(): void
|
public function testDoMapOfColumn(): void
|
||||||
{
|
{
|
||||||
@@ -238,7 +237,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
@@ -319,7 +318,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testGetPreProcessorName(): void
|
public function testGetPreProcessorName(): void
|
||||||
{
|
{
|
||||||
@@ -347,7 +346,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testGetReader(): void
|
public function testGetReader(): void
|
||||||
{
|
{
|
||||||
@@ -395,7 +394,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testGetValuesForMapping(): void
|
public function testGetValuesForMapping(): void
|
||||||
{
|
{
|
||||||
@@ -462,7 +461,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureMappingHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler
|
||||||
*/
|
*/
|
||||||
public function testSanitizeColumnName(): void
|
public function testSanitizeColumnName(): void
|
||||||
{
|
{
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Unit\Support\Import\Configuration\File;
|
namespace Tests\Unit\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
@@ -31,7 +31,7 @@ use FireflyIII\Import\Specifics\IngDescription;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@@ -43,7 +43,7 @@ use Tests\TestCase;
|
|||||||
class ConfigureRolesHandlerTest extends TestCase
|
class ConfigureRolesHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteBasic(): void
|
public function testConfigurationCompleteBasic(): void
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteForeign(): void
|
public function testConfigurationCompleteForeign(): void
|
||||||
{
|
{
|
||||||
@@ -87,7 +87,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteNoAmount(): void
|
public function testConfigurationCompleteNoAmount(): void
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
@@ -164,7 +164,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testGetExampleFromLine(): void
|
public function testGetExampleFromLine(): void
|
||||||
{
|
{
|
||||||
@@ -187,7 +187,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testGetExamplesFromFile(): void
|
public function testGetExamplesFromFile(): void
|
||||||
{
|
{
|
||||||
@@ -225,7 +225,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testGetHeadersHas(): void
|
public function testGetHeadersHas(): void
|
||||||
{
|
{
|
||||||
@@ -246,7 +246,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testGetHeadersNone(): void
|
public function testGetHeadersNone(): void
|
||||||
{
|
{
|
||||||
@@ -334,7 +334,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testGetReader(): void
|
public function testGetReader(): void
|
||||||
{
|
{
|
||||||
@@ -382,7 +382,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testIgnoreUnmappableColumns(): void
|
public function testIgnoreUnmappableColumns(): void
|
||||||
{
|
{
|
||||||
@@ -425,7 +425,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testIsMappingNecessaryNo(): void
|
public function testIsMappingNecessaryNo(): void
|
||||||
{
|
{
|
||||||
@@ -438,7 +438,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testIsMappingNecessaryYes(): void
|
public function testIsMappingNecessaryYes(): void
|
||||||
{
|
{
|
||||||
@@ -451,7 +451,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testMakeExamplesUnique(): void
|
public function testMakeExamplesUnique(): void
|
||||||
{
|
{
|
||||||
@@ -477,7 +477,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testProcessSpecifics(): void
|
public function testProcessSpecifics(): void
|
||||||
{
|
{
|
||||||
@@ -498,7 +498,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureRolesHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler
|
||||||
*/
|
*/
|
||||||
public function testSaveColumCount(): void
|
public function testSaveColumCount(): void
|
||||||
{
|
{
|
@@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Unit\Support\Import\Configuration\File;
|
namespace Tests\Unit\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ use Tests\TestCase;
|
|||||||
class ConfigureUploadHandlerTest extends TestCase
|
class ConfigureUploadHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJobAccount(): void
|
public function testConfigureJobAccount(): void
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJobNoAccount(): void
|
public function testConfigureJobNoAccount(): void
|
||||||
{
|
{
|
||||||
@@ -134,7 +134,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler
|
||||||
*/
|
*/
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
@@ -164,7 +164,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\ConfigureUploadHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler
|
||||||
*/
|
*/
|
||||||
public function testGetSpecifics(): void
|
public function testGetSpecifics(): void
|
||||||
{
|
{
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Unit\Support\Import\Configuration\File;
|
namespace Tests\Unit\Support\Import\JobConfiguration\File;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -29,7 +29,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\File\NewFileJobHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -40,7 +40,7 @@ use Tests\TestCase;
|
|||||||
class NewFileJobHandlerTest extends TestCase
|
class NewFileJobHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\NewFileJobHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ class NewFileJobHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\NewFileJobHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler
|
||||||
*/
|
*/
|
||||||
public function testConfigureJobBadData(): void
|
public function testConfigureJobBadData(): void
|
||||||
{
|
{
|
||||||
@@ -153,7 +153,7 @@ class NewFileJobHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\NewFileJobHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler
|
||||||
*/
|
*/
|
||||||
public function testStoreConfiguration(): void
|
public function testStoreConfiguration(): void
|
||||||
{
|
{
|
||||||
@@ -200,7 +200,7 @@ class NewFileJobHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\NewFileJobHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler
|
||||||
*/
|
*/
|
||||||
public function testValidateAttachments(): void
|
public function testValidateAttachments(): void
|
||||||
{
|
{
|
||||||
@@ -248,7 +248,7 @@ class NewFileJobHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Import\Configuration\File\NewFileJobHandler
|
* @covers \FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler
|
||||||
*/
|
*/
|
||||||
public function testValidateNotUTF(): void
|
public function testValidateNotUTF(): void
|
||||||
{
|
{
|
@@ -24,13 +24,22 @@ declare(strict_types=1);
|
|||||||
namespace tests\Unit\Support\Import\Routine\Spectre;
|
namespace tests\Unit\Support\Import\Routine\Spectre;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Models\Preference;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
|
use FireflyIII\Services\Spectre\Object\Attempt;
|
||||||
|
use FireflyIII\Services\Spectre\Object\Customer;
|
||||||
|
use FireflyIII\Services\Spectre\Object\Holder;
|
||||||
|
use FireflyIII\Services\Spectre\Object\Login;
|
||||||
use FireflyIII\Services\Spectre\Request\ListCustomersRequest;
|
use FireflyIII\Services\Spectre\Request\ListCustomersRequest;
|
||||||
use FireflyIII\Services\Spectre\Request\ListLoginsRequest;
|
use FireflyIII\Services\Spectre\Request\ListLoginsRequest;
|
||||||
use FireflyIII\Support\Import\Information\GetSpectreCustomerTrait;
|
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
|
||||||
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
|
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
|
||||||
use Tests\TestCase;
|
use Mockery;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StageNewHandlerTest
|
* Class StageNewHandlerTest
|
||||||
*/
|
*/
|
||||||
@@ -43,6 +52,7 @@ class StageNewHandlerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* run() with zero logins and a non-existing customer (must be created by Spectre).
|
* run() with zero logins and a non-existing customer (must be created by Spectre).
|
||||||
*
|
*
|
||||||
|
* @covers \FireflyIII\Support\Import\Information\GetSpectreCustomerTrait
|
||||||
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageNewHandler
|
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageNewHandler
|
||||||
*/
|
*/
|
||||||
public function testRunBasic(): void
|
public function testRunBasic(): void
|
||||||
@@ -57,24 +67,303 @@ class StageNewHandlerTest extends TestCase
|
|||||||
$job->configuration = [];
|
$job->configuration = [];
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
// mock classes:
|
// fake Spectre customer:
|
||||||
$trait = $this->mock(GetSpectreCustomerTrait::class);
|
$fakeCustomer = new Customer(
|
||||||
$llRequest = $this->mock(ListLoginsRequest::class);
|
[
|
||||||
$lcRequest = $this->mock(ListCustomersRequest::class);
|
'id' => 1,
|
||||||
|
'identifier' => 'fake',
|
||||||
|
'secret' => 'Dumbledore dies',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// mock calls for list logins
|
// mock classes:
|
||||||
|
$llRequest = $this->mock(ListLoginsRequest::class);
|
||||||
|
$lcRequest = $this->mock(ListCustomersRequest::class);
|
||||||
|
$ncRequest = $this->mock(NewCustomerRequest::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
// mock calls for list logins (return empty list for now).
|
||||||
|
$llRequest->shouldReceive('setUser')->once();
|
||||||
|
$llRequest->shouldReceive('setCustomer')->once();
|
||||||
|
$llRequest->shouldReceive('call')->once();
|
||||||
|
$llRequest->shouldReceive('getLogins')->once()->andReturn([]);
|
||||||
|
|
||||||
|
// mock calls for list customers (return empty list).
|
||||||
|
$lcRequest->shouldReceive('setUser')->once();
|
||||||
|
$lcRequest->shouldReceive('call')->once();
|
||||||
|
$lcRequest->shouldReceive('getCustomers')->once()->andReturn([]);
|
||||||
|
|
||||||
|
// create new customer:
|
||||||
|
$ncRequest->shouldReceive('setUser')->once();
|
||||||
|
$ncRequest->shouldReceive('getCustomer')->once()->andReturn($fakeCustomer);
|
||||||
|
|
||||||
|
// mock calls for repository:
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
$repository->shouldReceive('getConfiguration')->once()->withArgs([Mockery::any()])->andReturn([]);
|
||||||
|
|
||||||
|
// mock call for preferences
|
||||||
|
Preferences::shouldReceive('getForUser')->once()->withArgs([Mockery::any(), 'spectre_customer', null])->andReturnNull();
|
||||||
|
|
||||||
|
|
||||||
|
$handler = new StageNewHandler;
|
||||||
|
$handler->setImportJob($job);
|
||||||
|
try {
|
||||||
|
$handler->run();
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run() with zero logins and an existing customer (from preferences).
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Support\Import\Information\GetSpectreCustomerTrait
|
||||||
|
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageNewHandler
|
||||||
|
*/
|
||||||
|
public function testRunExistingCustomer(): void
|
||||||
|
{
|
||||||
|
$job = new ImportJob;
|
||||||
|
$job->user_id = $this->user()->id;
|
||||||
|
$job->key = 'sn_a_' . random_int(1, 1000);
|
||||||
|
$job->status = 'new';
|
||||||
|
$job->stage = 'new';
|
||||||
|
$job->provider = 'spectre';
|
||||||
|
$job->file_type = '';
|
||||||
|
$job->configuration = [];
|
||||||
|
$job->save();
|
||||||
|
|
||||||
|
$fakeCustomerPreference = new Preference;
|
||||||
|
$fakeCustomerPreference->name = 'spectre_customer';
|
||||||
|
$fakeCustomerPreference->data = [
|
||||||
|
'id' => 1,
|
||||||
|
'identifier' => 'fake',
|
||||||
|
'secret' => 'Dumbledore dies',
|
||||||
|
];
|
||||||
|
|
||||||
|
// mock classes:
|
||||||
|
$llRequest = $this->mock(ListLoginsRequest::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
// mock calls for list logins (return empty list for now).
|
||||||
$llRequest->shouldReceive('setUser')->once();
|
$llRequest->shouldReceive('setUser')->once();
|
||||||
$llRequest->shouldReceive('setCustomer')->once();
|
$llRequest->shouldReceive('setCustomer')->once();
|
||||||
$llRequest->shouldReceive('call')->once();
|
$llRequest->shouldReceive('call')->once();
|
||||||
$llRequest->shouldReceive('getLogins')->once()->andReturn([]);
|
$llRequest->shouldReceive('getLogins')->once()->andReturn([]);
|
||||||
|
|
||||||
// mock call for preferences
|
// mock call for preferences
|
||||||
// todo here we are
|
Preferences::shouldReceive('getForUser')->once()->withArgs([Mockery::any(), 'spectre_customer', null])->andReturn($fakeCustomerPreference);
|
||||||
Preferences::shouldReceive('getForUser');
|
|
||||||
|
|
||||||
|
// mock calls for repository:
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
$repository->shouldReceive('getConfiguration')->once()->withArgs([Mockery::any()])->andReturn([]);
|
||||||
|
|
||||||
$handler = new StageNewHandler;
|
$handler = new StageNewHandler;
|
||||||
$handler->setImportJob($job);
|
$handler->setImportJob($job);
|
||||||
$handler->run();
|
try {
|
||||||
|
$handler->run();
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run() with zero logins and multiple customers at Spectre (none in prefs)
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Support\Import\Information\GetSpectreCustomerTrait
|
||||||
|
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageNewHandler
|
||||||
|
*/
|
||||||
|
public function testRunMultiCustomer(): void
|
||||||
|
{
|
||||||
|
$job = new ImportJob;
|
||||||
|
$job->user_id = $this->user()->id;
|
||||||
|
$job->key = 'sn_a_' . random_int(1, 1000);
|
||||||
|
$job->status = 'new';
|
||||||
|
$job->stage = 'new';
|
||||||
|
$job->provider = 'spectre';
|
||||||
|
$job->file_type = '';
|
||||||
|
$job->configuration = [];
|
||||||
|
$job->save();
|
||||||
|
|
||||||
|
// fake Spectre customer:
|
||||||
|
$fakeCustomer = new Customer(
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'identifier' => 'fake',
|
||||||
|
'secret' => 'Dumbledore dies',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$correctCustomer = new Customer(
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'identifier' => 'default_ff3_customer',
|
||||||
|
'secret' => 'Firefly III',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock classes:
|
||||||
|
$llRequest = $this->mock(ListLoginsRequest::class);
|
||||||
|
$lcRequest = $this->mock(ListCustomersRequest::class);
|
||||||
|
$ncRequest = $this->mock(NewCustomerRequest::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock calls for list logins (return empty list for now).
|
||||||
|
$llRequest->shouldReceive('setUser')->once();
|
||||||
|
$llRequest->shouldReceive('setCustomer')->once();
|
||||||
|
$llRequest->shouldReceive('call')->once();
|
||||||
|
$llRequest->shouldReceive('getLogins')->once()->andReturn([]);
|
||||||
|
|
||||||
|
// mock calls for list customers (return empty list).
|
||||||
|
$lcRequest->shouldReceive('setUser')->once();
|
||||||
|
$lcRequest->shouldReceive('call')->once();
|
||||||
|
$lcRequest->shouldReceive('getCustomers')->once()->andReturn([$fakeCustomer, $correctCustomer]);
|
||||||
|
|
||||||
|
// mock calls for repository:
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
$repository->shouldReceive('getConfiguration')->once()->withArgs([Mockery::any()])->andReturn([]);
|
||||||
|
|
||||||
|
// mock call for preferences
|
||||||
|
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'spectre_customer', null])->andReturnNull()->once();
|
||||||
|
Preferences::shouldReceive('setForUser')->withArgs([Mockery::any(), 'spectre_customer', $correctCustomer->toArray()])->once();
|
||||||
|
|
||||||
|
$handler = new StageNewHandler;
|
||||||
|
$handler->setImportJob($job);
|
||||||
|
try {
|
||||||
|
$handler->run();
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run() with one login and multiple customers at Spectre (none in prefs)
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Support\Import\Information\GetSpectreCustomerTrait
|
||||||
|
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageNewHandler
|
||||||
|
*/
|
||||||
|
public function testRunMultiCustomerLogin(): void
|
||||||
|
{
|
||||||
|
$job = new ImportJob;
|
||||||
|
$job->user_id = $this->user()->id;
|
||||||
|
$job->key = 'sn_a_' . random_int(1, 1000);
|
||||||
|
$job->status = 'new';
|
||||||
|
$job->stage = 'new';
|
||||||
|
$job->provider = 'spectre';
|
||||||
|
$job->file_type = '';
|
||||||
|
$job->configuration = [];
|
||||||
|
$job->save();
|
||||||
|
|
||||||
|
// fake Spectre customer:
|
||||||
|
$fakeCustomer = new Customer(
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'identifier' => 'fake',
|
||||||
|
'secret' => 'Dumbledore dies',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$correctCustomer = new Customer(
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'identifier' => 'default_ff3_customer',
|
||||||
|
'secret' => 'Firefly III',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// fake login:
|
||||||
|
$holder = new Holder([]);
|
||||||
|
$attempt = new Attempt(
|
||||||
|
[
|
||||||
|
'api_mode' => 'x',
|
||||||
|
'api_version' => 4,
|
||||||
|
'automatic_fetch' => true,
|
||||||
|
'categorize' => true,
|
||||||
|
'created_at' => '2018-05-21 12:00:00',
|
||||||
|
'consent_given_at' => '2018-05-21 12:00:00',
|
||||||
|
'consent_types' => ['transactions'],
|
||||||
|
'custom_fields' => [],
|
||||||
|
'daily_refresh' => true,
|
||||||
|
'device_type' => 'mobile',
|
||||||
|
'user_agent' => 'Mozilla/x',
|
||||||
|
'remote_ip' => '127.0.0.1',
|
||||||
|
'exclude_accounts' => [],
|
||||||
|
'fail_at' => '2018-05-21 12:00:00',
|
||||||
|
'fail_error_class' => 'err',
|
||||||
|
'fail_message' => 'message',
|
||||||
|
'fetch_scopes' => [],
|
||||||
|
'finished' => true,
|
||||||
|
'finished_recent' => true,
|
||||||
|
'from_date' => '2018-05-21 12:00:00',
|
||||||
|
'id' => 1,
|
||||||
|
'interactive' => true,
|
||||||
|
'locale' => 'en',
|
||||||
|
'partial' => true,
|
||||||
|
'show_consent_confirmation' => true,
|
||||||
|
'stages' => [],
|
||||||
|
'store_credentials' => true,
|
||||||
|
'success_at' => '2018-05-21 12:00:00',
|
||||||
|
'to_date' => '2018-05-21 12:00:00',
|
||||||
|
'updated_at' => '2018-05-21 12:00:00',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$login = new Login(
|
||||||
|
[
|
||||||
|
'consent_given_at' => '2018-05-21 12:00:00',
|
||||||
|
'consent_types' => ['transactions'],
|
||||||
|
'country_code' => 'NL',
|
||||||
|
'created_at' => '2018-05-21 12:00:00',
|
||||||
|
'updated_at' => '2018-05-21 12:00:00',
|
||||||
|
'customer_id' => '1',
|
||||||
|
'daily_refresh' => true,
|
||||||
|
'holder_info' => $holder->toArray(),
|
||||||
|
'id' => 123,
|
||||||
|
'last_attempt' => $attempt->toArray(),
|
||||||
|
'last_success_at' => '2018-05-21 12:00:00',
|
||||||
|
'next_refresh_possible_at' => '2018-05-21 12:00:00',
|
||||||
|
'provider_code' => 'XF',
|
||||||
|
'provider_id' => '123',
|
||||||
|
'provider_name' => 'Fake',
|
||||||
|
'show_consent_confirmation' => true,
|
||||||
|
'status' => 'active',
|
||||||
|
'store_credentials' => true,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock classes:
|
||||||
|
$llRequest = $this->mock(ListLoginsRequest::class);
|
||||||
|
$lcRequest = $this->mock(ListCustomersRequest::class);
|
||||||
|
$ncRequest = $this->mock(NewCustomerRequest::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock calls for list logins (return empty list for now).
|
||||||
|
$llRequest->shouldReceive('setUser')->once();
|
||||||
|
$llRequest->shouldReceive('setCustomer')->once();
|
||||||
|
$llRequest->shouldReceive('call')->once();
|
||||||
|
$llRequest->shouldReceive('getLogins')->once()->andReturn([$login]);
|
||||||
|
|
||||||
|
// mock calls for list customers (return empty list).
|
||||||
|
$lcRequest->shouldReceive('setUser')->once();
|
||||||
|
$lcRequest->shouldReceive('call')->once();
|
||||||
|
$lcRequest->shouldReceive('getCustomers')->once()->andReturn([$fakeCustomer, $correctCustomer]);
|
||||||
|
|
||||||
|
// mock call for preferences
|
||||||
|
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'spectre_customer', null])->andReturnNull()->once();
|
||||||
|
Preferences::shouldReceive('setForUser')->withArgs([Mockery::any(), 'spectre_customer', $correctCustomer->toArray()])->once();
|
||||||
|
|
||||||
|
// mock calls for repository:
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
$repository->shouldReceive('getConfiguration')->once()->withArgs([Mockery::any()])->andReturn([]);
|
||||||
|
$repository->shouldReceive('setConfiguration')->once()
|
||||||
|
->withArgs([Mockery::any(), ['all-logins' => [$login->toArray()]]]);
|
||||||
|
|
||||||
|
$handler = new StageNewHandler;
|
||||||
|
$handler->setImportJob($job);
|
||||||
|
try {
|
||||||
|
$handler->run();
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user