Fix test coverage, ignore all other routines.

This commit is contained in:
James Cole 2018-05-05 06:47:35 +02:00
parent 1c0da454db
commit 57be7f2905
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
16 changed files with 202 additions and 580 deletions

View File

@ -29,6 +29,8 @@ use FireflyIII\Support\Import\Configuration\Bunq\HaveAccounts;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class BunqConfigurator.
*/
class BunqConfigurator implements ConfiguratorInterface

View File

@ -25,6 +25,8 @@ namespace FireflyIII\Import\Configuration;
use FireflyIII\Models\ImportJob;
/**
* @deprecated
* @codeCoverageIgnore
* Interface ConfiguratorInterface.
*/
interface ConfiguratorInterface

View File

@ -33,6 +33,8 @@ use FireflyIII\Support\Import\Configuration\File\UploadConfig;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class FileConfigurator.
*/
class FileConfigurator implements ConfiguratorInterface

View File

@ -29,6 +29,8 @@ use FireflyIII\Support\Import\Configuration\Spectre\HaveAccounts;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class SpectreConfigurator.
*/
class SpectreConfigurator implements ConfiguratorInterface

View File

@ -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.

View File

@ -1,157 +0,0 @@
<?php
namespace FireflyIII\Import\JobConfiguration;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
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 Illuminate\Support\MessageBag;
use Log;
/**
* Class FileJobConfiguration
*
* @package FireflyIII\Import\JobConfiguration
*/
class FileJobConfiguration implements JobConfigurationInterface
{
/** @var ImportJob */
private $job;
/** @var ImportJobRepositoryInterface */
private $repository;
/**
* ConfiguratorInterface constructor.
*/
public function __construct()
{
$this->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;
}
}

View File

@ -1,71 +0,0 @@
<?php
/**
* CommandHandler.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\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));
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -58,6 +58,8 @@ use Log;
use Preferences;
/**
* @deprecated
* @codeCoverageIgnore
* Class BunqRoutine
*
* Steps before import:

View File

@ -35,6 +35,8 @@ use Illuminate\Support\Collection;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class FileRoutine
*/
class FileRoutine implements RoutineInterface

View File

@ -48,6 +48,8 @@ use Log;
use Preferences;
/**
* @deprecated
* @codeCoverageIgnore
* Class FileRoutine
*/
class SpectreRoutine implements RoutineInterface

View File

@ -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

View File

@ -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('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::order
*/
public function testOrder()
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('reset');
$repository->shouldReceive('setOrder')->times(2);
$this->be($this->user());
$response = $this->post(route('piggy-banks.order'), ['order' => [1, 2]]);
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
*/
public function testPostAdd()
public function testPostAdd(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -255,7 +240,7 @@ class PiggyBankControllerTest extends TestCase
*
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
*/
public function testPostAddTooMuch()
public function testPostAddTooMuch(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -274,7 +259,7 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
*/
public function testPostRemove()
public function testPostRemove(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -294,7 +279,7 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
*/
public function testPostRemoveTooMuch()
public function testPostRemoveTooMuch(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -313,7 +298,7 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::remove
*/
public function testRemove()
public function testRemove(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
@ -327,7 +312,7 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::removeMobile
*/
public function testRemoveMobile()
public function testRemoveMobile(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
@ -342,7 +327,7 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::show
*/
public function testShow()
public function testShow(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -360,7 +345,7 @@ class PiggyBankControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\PiggyBankController::store
* @covers \FireflyIII\Http\Requests\PiggyBankFormRequest
*/
public function testStore()
public function testStore(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
@ -386,7 +371,7 @@ class PiggyBankControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
* @covers \FireflyIII\Http\Requests\PiggyBankFormRequest
*/
public function testUpdate()
public function testUpdate(): void
{
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);

File diff suppressed because it is too large Load Diff