mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code consistency and new tests.
This commit is contained in:
@@ -33,7 +33,7 @@ use Illuminate\Support\MessageBag;
|
||||
class FakeJobConfiguration implements JobConfigurationInterface
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $job;
|
||||
private $importJob;
|
||||
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
@@ -57,8 +57,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
|
||||
// 'artist' must be 'david bowie', case insensitive
|
||||
// 'song' must be 'golden years', case insensitive.
|
||||
// if stage is not "new", then album must be 'station to station'
|
||||
$config = $this->job->configuration;
|
||||
if ($this->job->stage === 'new') {
|
||||
$config = $this->importJob->configuration;
|
||||
if ($this->importJob->stage === 'new') {
|
||||
return (isset($config['artist']) && 'david bowie' === strtolower($config['artist']))
|
||||
&& (isset($config['song']) && 'golden years' === strtolower($config['song']))
|
||||
&& isset($config['apply-rules']);
|
||||
@@ -82,7 +82,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
|
||||
$song = strtolower($data['song'] ?? '');
|
||||
$album = strtolower($data['album'] ?? '');
|
||||
$applyRules = isset($data['apply_rules']) ? (int)$data['apply_rules'] === 1 : null;
|
||||
$configuration = $this->job->configuration;
|
||||
$configuration = $this->importJob->configuration;
|
||||
if ($artist === 'david bowie') {
|
||||
// store artist
|
||||
$configuration['artist'] = $artist;
|
||||
@@ -101,7 +101,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
|
||||
$configuration['apply-rules'] = $applyRules;
|
||||
}
|
||||
|
||||
$this->repository->setConfiguration($this->job, $configuration);
|
||||
$this->repository->setConfiguration($this->importJob, $configuration);
|
||||
$messages = new MessageBag();
|
||||
|
||||
if (\count($configuration) !== 3) {
|
||||
@@ -135,7 +135,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
|
||||
public function getNextView(): string
|
||||
{
|
||||
// first configure artist:
|
||||
$config = $this->job->configuration;
|
||||
$config = $this->importJob->configuration;
|
||||
$artist = $config['artist'] ?? '';
|
||||
$song = $config['song'] ?? '';
|
||||
$album = $config['album'] ?? '';
|
||||
@@ -149,18 +149,18 @@ class FakeJobConfiguration implements JobConfigurationInterface
|
||||
if (strtolower($song) !== 'golden years') {
|
||||
return 'import.fake.enter-song';
|
||||
}
|
||||
if (strtolower($album) !== 'station to station' && $this->job->stage !== 'new') {
|
||||
if (strtolower($album) !== 'station to station' && $this->importJob->stage !== 'new') {
|
||||
return 'import.fake.enter-album';
|
||||
}
|
||||
return 'impossible-view'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setJob(ImportJob $job): void
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->job = $job;
|
||||
$this->repository->setUser($job->user);
|
||||
$this->importJob = $importJob;
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class FileJobConfiguration implements JobConfigurationInterface
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
$configurator = $this->getConfigurationObject();
|
||||
$configurator->setJob($this->importJob);
|
||||
$configurator->setImportJob($this->importJob);
|
||||
|
||||
return $configurator->configureJob($data);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class FileJobConfiguration implements JobConfigurationInterface
|
||||
public function getNextData(): array
|
||||
{
|
||||
$configurator = $this->getConfigurationObject();
|
||||
$configurator->setJob($this->importJob);
|
||||
$configurator->setImportJob($this->importJob);
|
||||
|
||||
return $configurator->getNextData();
|
||||
}
|
||||
@@ -124,12 +124,12 @@ class FileJobConfiguration implements JobConfigurationInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setJob(ImportJob $job): void
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $job;
|
||||
$this->repository->setUser($job->user);
|
||||
$this->importJob = $importJob;
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -35,6 +35,13 @@ interface JobConfigurationInterface
|
||||
*/
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* Returns true when the initial configuration for this job is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool;
|
||||
|
||||
/**
|
||||
* Store any data from the $data array into the job. Anything in the message bag will be flashed
|
||||
* as an error to the user, regardless of its content.
|
||||
@@ -60,14 +67,7 @@ interface JobConfigurationInterface
|
||||
public function getNextView(): string;
|
||||
|
||||
/**
|
||||
* Returns true when the initial configuration for this job is complete.
|
||||
*
|
||||
* @return bool
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function configurationComplete(): bool;
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job): void;
|
||||
public function setImportJob(ImportJob $importJob): void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user