FF3 will apply rules when importing from bunq #1443

This commit is contained in:
James Cole
2018-06-01 05:49:33 +02:00
parent 3fbe851a0b
commit df87d03f32
4 changed files with 82 additions and 698 deletions

View File

@@ -0,0 +1,67 @@
<?php
/**
* NewBunqJobHandlerTest.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 Tests\Unit\Support\Import\JobConfiguration\Bunq;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\JobConfiguration\Bunq\NewBunqJobHandler;
use Mockery;
use Tests\TestCase;
class NewBunqJobHandlerTest extends TestCase
{
/**
* @covers \FireflyIII\Support\Import\JobConfiguration\Bunq\NewBunqJobHandler
*/
public function testCC(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'cXha' . random_int(1, 1000);
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';
$job->file_type = '';
$job->configuration = [];
$job->save();
// expected config:
$expected = [
'apply-rules' => true,
];
// mock stuff
$repository = $this->mock(ImportJobRepositoryInterface::class);
// mock calls
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('getConfiguration')->andReturn([])->once();
$repository->shouldReceive('setConfiguration')->withArgs([Mockery::any(), $expected])->once();
$handler = new NewBunqJobHandler();
$handler->setImportJob($job);
$this->assertTrue($handler->configurationComplete());
}
}