Fix export controller tests.

This commit is contained in:
James Cole 2017-01-02 09:23:24 +01:00
parent 87316cf7c1
commit 7c5bed2bb5
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 16 additions and 3 deletions

View File

@ -124,7 +124,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/**
* @param string $key
*
* @return ExportJob|null
* @return ExportJob
*/
public function findByKey(string $key): ExportJob
{

View File

@ -8,9 +8,13 @@
*
* See the LICENSE file for details.
*/
use Carbon\Carbon;
use FireflyIII\Export\Processor;
use FireflyIII\Export\ProcessorInterface;
use FireflyIII\Models\ExportJob;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:41.
@ -70,6 +74,11 @@ class ExportControllerTest extends TestCase
*/
public function testPostIndex()
{
$this->session(
['first' => new Carbon('2014-01-01')]
);
$data = [
'export_start_range' => '2015-01-01',
@ -78,7 +87,11 @@ class ExportControllerTest extends TestCase
'accounts' => [1],
'job' => 'testExport',
];
$processor = $this->mock(Processor::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$accountRepository->shouldReceive('getAccountsById')->withArgs([$data['accounts']])->andReturn(new Collection);
$processor = $this->mock(ProcessorInterface::class);
$processor->shouldReceive('collectJournals')->once();
$processor->shouldReceive('convertJournals')->once();
$processor->shouldReceive('exportJournals')->once();
@ -88,8 +101,8 @@ class ExportControllerTest extends TestCase
$repository->shouldReceive('changeStatus')->andReturn(true);
$repository->shouldReceive('findByKey')->andReturn(new ExportJob);
$this->be($this->user());
$this->call('post', route('export.export'), $data);
$this->assertResponseStatus(200);
$this->see('ok');