2016-11-19 13:30:30 -06:00
|
|
|
<?php
|
2016-12-06 02:16:36 -06:00
|
|
|
/**
|
|
|
|
* ExportControllerTest.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
*/
|
2016-12-11 11:34:18 -06:00
|
|
|
use FireflyIII\Export\Processor;
|
2016-11-19 13:30:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-09 23:54:50 -06:00
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:41.
|
2016-11-19 13:30:30 -06:00
|
|
|
*/
|
|
|
|
class ExportControllerTest extends TestCase
|
|
|
|
{
|
2016-11-20 00:24:18 -06:00
|
|
|
|
2016-11-19 13:30:30 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
|
|
* This method is called before a test is executed.
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
2016-11-20 01:30:25 -06:00
|
|
|
parent::setUp();
|
2016-11-19 13:30:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 12:53:41 -06:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ExportController::download
|
2016-11-19 13:30:30 -06:00
|
|
|
*/
|
|
|
|
public function testDownload()
|
|
|
|
{
|
2016-12-11 11:34:18 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('export.download', ['testExport']));
|
|
|
|
$this->assertResponseStatus(200);
|
2016-11-19 13:30:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 12:53:41 -06:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ExportController::getStatus
|
2016-11-19 13:30:30 -06:00
|
|
|
*/
|
|
|
|
public function testGetStatus()
|
|
|
|
{
|
2016-12-11 11:34:18 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('export.status', ['testExport']));
|
|
|
|
$this->assertResponseStatus(200);
|
2016-11-19 13:30:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 12:53:41 -06:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ExportController::index
|
2016-11-19 13:30:30 -06:00
|
|
|
*/
|
|
|
|
public function testIndex()
|
|
|
|
{
|
2016-12-11 11:34:18 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('export.index'));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
|
|
|
|
// has bread crumb
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 13:30:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 12:53:41 -06:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ExportController::postIndex
|
2016-11-19 13:30:30 -06:00
|
|
|
*/
|
|
|
|
public function testPostIndex()
|
|
|
|
{
|
2016-12-11 11:34:18 -06:00
|
|
|
$data = [
|
2016-11-20 04:43:19 -06:00
|
|
|
|
2016-12-11 11:34:18 -06:00
|
|
|
'export_start_range' => '2015-01-01',
|
|
|
|
'export_end_range' => '2015-01-21',
|
|
|
|
'exportFormat' => 'csv',
|
|
|
|
'accounts' => [1],
|
|
|
|
'job' => 'testExport',
|
|
|
|
];
|
|
|
|
$processor = $this->mock(Processor::class);
|
|
|
|
$processor->shouldReceive('collectJournals')->once();
|
|
|
|
$processor->shouldReceive('convertJournals')->once();
|
|
|
|
$processor->shouldReceive('exportJournals')->once();
|
|
|
|
$processor->shouldReceive('createZipFile')->once();
|
|
|
|
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('export.export'), $data);
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('ok');
|
2016-11-20 04:43:19 -06:00
|
|
|
}
|
2016-12-11 11:34:18 -06:00
|
|
|
|
2016-11-19 13:30:30 -06:00
|
|
|
}
|