2016-11-19 20:30:30 +01:00
|
|
|
<?php
|
2016-12-06 09:16:36 +01:00
|
|
|
/**
|
|
|
|
* ImportControllerTest.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-17 08:35:03 +01:00
|
|
|
use FireflyIII\Import\Setup\CsvSetup;
|
2016-12-17 19:19:49 +01:00
|
|
|
use Illuminate\Http\UploadedFile;
|
2016-11-19 20:30:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-10 06:54:50 +01:00
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:41.
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
class ImportControllerTest extends TestCase
|
|
|
|
{
|
2016-11-20 07:24:18 +01:00
|
|
|
|
2016-11-19 20:30:30 +01: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 08:30:25 +01:00
|
|
|
parent::setUp();
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
2016-12-07 19:53:41 +01:00
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::complete
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testComplete()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.complete', ['complete']));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::configure
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testConfigure()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.configure', ['configure']));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::download
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testDownload()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.download', ['configure']));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('[]');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::finished
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testFinished()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.finished', ['finished']));
|
|
|
|
$this->assertResponseStatus(200);
|
|
|
|
$this->see('<ol class="breadcrumb">');
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::index
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testIndex()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.index'));
|
|
|
|
$this->assertResponseStatus(200);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::json
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testJson()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('GET', route('import.json', ['configure']));
|
|
|
|
$this->assertResponseStatus(200);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::postConfigure
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testPostConfigure()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$importer = $this->mock(CsvSetup::class);
|
|
|
|
$importer->shouldReceive('setJob')->once();
|
|
|
|
$importer->shouldReceive('saveImportConfiguration')->once();
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('import.process-configuration', ['p-configure']), $data);
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertRedirectedToRoute('import.settings', ['p-configure']);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::postSettings
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testPostSettings()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$importer = $this->mock(CsvSetup::class);
|
|
|
|
$importer->shouldReceive('setJob')->once();
|
|
|
|
$importer->shouldReceive('storeSettings')->once();
|
|
|
|
$data = [];
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('import.post-settings', ['p-settings']), $data);
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertRedirectedToRoute('import.settings', ['p-settings']);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::settings
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testSettings()
|
|
|
|
{
|
2016-12-17 08:35:03 +01:00
|
|
|
$importer = $this->mock(CsvSetup::class);
|
|
|
|
$importer->shouldReceive('setJob')->once();
|
|
|
|
$importer->shouldReceive('requireUserSettings')->once()->andReturn(false);
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('import.settings', ['settings']));
|
|
|
|
$this->assertResponseStatus(302);
|
|
|
|
$this->assertRedirectedToRoute('import.complete', ['settings']);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::start
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testStart()
|
|
|
|
{
|
2016-12-17 19:19:49 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('post', route('import.start', ['complete']));
|
|
|
|
$this->assertResponseStatus(200);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::status
|
2016-11-26 08:55:26 +01:00
|
|
|
* Implement testStatus().
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testStatus()
|
|
|
|
{
|
2016-12-17 19:19:49 +01:00
|
|
|
// complete
|
|
|
|
$this->be($this->user());
|
|
|
|
$this->call('get', route('import.status', ['complete']));
|
|
|
|
$this->assertResponseStatus(302);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-07 19:53:41 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\ImportController::upload
|
2016-11-19 20:30:30 +01:00
|
|
|
*/
|
|
|
|
public function testUpload()
|
|
|
|
{
|
2016-12-17 19:19:49 +01:00
|
|
|
$path = resource_path('stubs/csv.csv');
|
|
|
|
$file = new UploadedFile($path, 'upload.csv', filesize($path), 'text/csv', null, true);
|
|
|
|
$this->call('POST', route('import.upload'), [], [], ['import_file' => $file], ['Accept' => 'application/json']);
|
|
|
|
$this->assertResponseStatus(302);
|
2016-11-19 20:30:30 +01:00
|
|
|
}
|
|
|
|
}
|