diff --git a/app/Import/Configuration/BunqConfigurator.php b/app/Import/Configuration/BunqConfigurator.php index 910c494d71..a115f8e933 100644 --- a/app/Import/Configuration/BunqConfigurator.php +++ b/app/Import/Configuration/BunqConfigurator.php @@ -29,6 +29,8 @@ use FireflyIII\Support\Import\Configuration\Bunq\HaveAccounts; use Log; /** + * @deprecated + * @codeCoverageIgnore * Class BunqConfigurator. */ class BunqConfigurator implements ConfiguratorInterface diff --git a/app/Import/Configuration/ConfiguratorInterface.php b/app/Import/Configuration/ConfiguratorInterface.php index f171044f7c..a1e961b0ec 100644 --- a/app/Import/Configuration/ConfiguratorInterface.php +++ b/app/Import/Configuration/ConfiguratorInterface.php @@ -25,6 +25,8 @@ namespace FireflyIII\Import\Configuration; use FireflyIII\Models\ImportJob; /** + * @deprecated + * @codeCoverageIgnore * Interface ConfiguratorInterface. */ interface ConfiguratorInterface diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.php index 4d98232d2a..b525d1c40e 100644 --- a/app/Import/Configuration/FileConfigurator.php +++ b/app/Import/Configuration/FileConfigurator.php @@ -33,6 +33,8 @@ use FireflyIII\Support\Import\Configuration\File\UploadConfig; use Log; /** + * @deprecated + * @codeCoverageIgnore * Class FileConfigurator. */ class FileConfigurator implements ConfiguratorInterface diff --git a/app/Import/Configuration/SpectreConfigurator.php b/app/Import/Configuration/SpectreConfigurator.php index 3f65633d3a..a71953ed4b 100644 --- a/app/Import/Configuration/SpectreConfigurator.php +++ b/app/Import/Configuration/SpectreConfigurator.php @@ -29,6 +29,8 @@ use FireflyIII\Support\Import\Configuration\Spectre\HaveAccounts; use Log; /** + * @deprecated + * @codeCoverageIgnore * Class SpectreConfigurator. */ class SpectreConfigurator implements ConfiguratorInterface diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php index affd463daa..deba0399d5 100644 --- a/app/Import/FileProcessor/CsvProcessor.php +++ b/app/Import/FileProcessor/CsvProcessor.php @@ -33,6 +33,9 @@ use League\Csv\Statement; use Log; /** + * @deprecated + * @codeCoverageIgnore + * * Class CsvProcessor, as the name suggests, goes over CSV file line by line and creates * "ImportJournal" objects, which are used in another step to create new journals and transactions * and what-not. diff --git a/app/Import/JobConfiguration/FileJobConfiguration.php b/app/Import/JobConfiguration/FileJobConfiguration.php deleted file mode 100644 index 7f486a0125..0000000000 --- a/app/Import/JobConfiguration/FileJobConfiguration.php +++ /dev/null @@ -1,157 +0,0 @@ -repository = app(ImportJobRepositoryInterface::class); - } - - /** - * 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. - * - * @param array $data - * - * @return MessageBag - * @throws FireflyException - */ - public function configureJob(array $data): MessageBag - { - /** @var ConfigurationInterface $object */ - $object = app($this->getConfigurationClass()); - $object->setJob($this->job); - $result = $object->storeConfiguration($data); - - return $result; - } - - /** - * Return the data required for the next step in the job configuration. - * - * @return array - * @throws FireflyException - */ - public function getNextData(): array - { - /** @var ConfigurationInterface $object */ - $object = app($this->getConfigurationClass()); - $object->setJob($this->job); - - return $object->getData(); - } - - /** - * Returns the view of the next step in the job configuration. - * - * @return string - * @throws FireflyException - */ - public function getNextView(): string - { - switch ($this->job->stage) { - case 'new': // has nothing, no file upload or anything. - return 'import.file.new'; - 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"', $this->job->stage)); - } - - /** - * Returns true when the initial configuration for this job is complete. - * - * @return bool - */ - public function configurationComplete(): bool - { - if ('ready' === $this->job->stage) { - Log::debug('isJobConfigured returns true'); - - return true; - } - Log::debug('isJobConfigured returns false'); - - return false; - } - - /** - * @param ImportJob $job - */ - public function setJob(ImportJob $job): void - { - $this->job = $job; - $this->repository->setUser($job->user); - } - - - /** - * @return string - * - * @throws FireflyException - */ - private function getConfigurationClass(): string - { - $class = false; - Log::debug(sprintf('Now in getConfigurationClass() for stage "%s"', $this->job->stage)); - - switch ($this->job->stage) { - case 'new': // 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().', $this->job->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; - } -} \ No newline at end of file diff --git a/app/Import/Logging/CommandHandler.php b/app/Import/Logging/CommandHandler.php deleted file mode 100644 index c1dfc85773..0000000000 --- a/app/Import/Logging/CommandHandler.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ -declare(strict_types=1); - -namespace FireflyIII\Import\Logging; - -use Illuminate\Console\Command; -use Monolog\Handler\AbstractProcessingHandler; - -/** - * @codeCoverageIgnore - * Class CommandHandler. - */ -class CommandHandler extends AbstractProcessingHandler -{ - /** @var Command */ - private $command; - - /** - * Handler constructor. - * - * @param Command $command - */ - public function __construct(Command $command) - { - parent::__construct(); - $this->command = $command; - - $this->changeLevel(env('APP_LOG_LEVEL', 'info')); - } - - /** - * Writes the record down to the log of the implementing handler. - * - * @param array $record - */ - protected function write(array $record) - { - $this->command->line(trim($record['formatted'])); - } - - /** - * @param string $level - */ - private function changeLevel(string $level) - { - $level = strtoupper($level); - $reference = sprintf('\Monolog\Logger::%s', $level); - if (\defined($reference)) { - $this->setLevel(\constant($reference)); - } - } -} diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.php index feaa23d477..f1f93aab3e 100644 --- a/app/Import/Prerequisites/BunqPrerequisites.php +++ b/app/Import/Prerequisites/BunqPrerequisites.php @@ -30,6 +30,8 @@ use Log; use Preferences; /** + * @deprecated + * @codeCoverageIgnore * This class contains all the routines necessary to connect to Bunq. */ class BunqPrerequisites implements PrerequisitesInterface diff --git a/app/Import/Prerequisites/FilePrerequisites.php b/app/Import/Prerequisites/FilePrerequisites.php index c574cfa05b..ad299fee09 100644 --- a/app/Import/Prerequisites/FilePrerequisites.php +++ b/app/Import/Prerequisites/FilePrerequisites.php @@ -28,6 +28,8 @@ use Illuminate\Http\Request; use Illuminate\Support\MessageBag; /** + * @deprecated + * @codeCoverageIgnore * This class contains all the routines necessary to import from a file. Hint: there are none. */ class FilePrerequisites implements PrerequisitesInterface diff --git a/app/Import/Prerequisites/SpectrePrerequisites.php b/app/Import/Prerequisites/SpectrePrerequisites.php index 7da7d93942..1905ea2b6f 100644 --- a/app/Import/Prerequisites/SpectrePrerequisites.php +++ b/app/Import/Prerequisites/SpectrePrerequisites.php @@ -30,6 +30,8 @@ use Log; use Preferences; /** + * @deprecated + * @codeCoverageIgnore * This class contains all the routines necessary to connect to Spectre. */ class SpectrePrerequisites implements PrerequisitesInterface diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php index ff4b79112e..1d705eba93 100644 --- a/app/Import/Routine/BunqRoutine.php +++ b/app/Import/Routine/BunqRoutine.php @@ -58,6 +58,8 @@ use Log; use Preferences; /** + * @deprecated + * @codeCoverageIgnore * Class BunqRoutine * * Steps before import: diff --git a/app/Import/Routine/FileRoutine.php b/app/Import/Routine/FileRoutine.php index a685eeac1d..a6ce949dea 100644 --- a/app/Import/Routine/FileRoutine.php +++ b/app/Import/Routine/FileRoutine.php @@ -35,6 +35,8 @@ use Illuminate\Support\Collection; use Log; /** + * @deprecated + * @codeCoverageIgnore * Class FileRoutine */ class FileRoutine implements RoutineInterface diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.php index abde781fad..16eeba2c65 100644 --- a/app/Import/Routine/SpectreRoutine.php +++ b/app/Import/Routine/SpectreRoutine.php @@ -48,6 +48,8 @@ use Log; use Preferences; /** + * @deprecated + * @codeCoverageIgnore * Class FileRoutine */ class SpectreRoutine implements RoutineInterface diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index 99ee41171d..ac4c0d153c 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -40,6 +40,8 @@ class ImportArrayStorage private $transfers; /** + * Set job, count transfers in the array and create the repository. + * * @param ImportJob $importJob */ public function setJob(ImportJob $importJob): void @@ -86,6 +88,8 @@ class ImportArrayStorage } /** + * Applies the users rules to the created journals. + * * @param Collection $collection * * @throws FireflyException @@ -135,6 +139,8 @@ class ImportArrayStorage } /** + * Gets the users rules. + * * @return Collection */ private function getRules(): Collection @@ -173,6 +179,8 @@ class ImportArrayStorage } /** + * Check if the hash exists for the array the user wants to import. + * * @param array $transaction * * @return int|null @@ -202,6 +210,8 @@ class ImportArrayStorage } /** + * Link all imported journals to a tag. + * * @param Collection $collection */ private function linkToTag(Collection $collection): void @@ -235,6 +245,8 @@ class ImportArrayStorage } /** + * Log about a duplicate object (double hash). + * * @param array $transaction * @param int $existingId */ @@ -253,6 +265,8 @@ class ImportArrayStorage } /** + * Log about a duplicate transfer. + * * @param array $transaction */ private function logDuplicateTransfer(array $transaction): void diff --git a/tests/Feature/Controllers/PiggyBankControllerTest.php b/tests/Feature/Controllers/PiggyBankControllerTest.php index 57a4fd3471..558ef244f9 100644 --- a/tests/Feature/Controllers/PiggyBankControllerTest.php +++ b/tests/Feature/Controllers/PiggyBankControllerTest.php @@ -204,6 +204,8 @@ class PiggyBankControllerTest extends TestCase $repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$one, $two])); $repository->shouldReceive('getCurrentAmount')->andReturn('10'); $repository->shouldReceive('setUser'); + $repository->shouldReceive('correctOrder'); + Steam::shouldReceive('balance')->twice()->andReturn('1'); @@ -213,27 +215,10 @@ class PiggyBankControllerTest extends TestCase $response->assertSee('