Import related tests.

This commit is contained in:
James Cole 2016-12-17 08:35:03 +01:00
parent 4de14eba0c
commit 9165e0238f
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 171 additions and 53 deletions

View File

@ -18,6 +18,7 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Rule;
@ -416,6 +417,35 @@ Breadcrumbs::register(
}
);
/**
* IMPORT
*/
Breadcrumbs::register(
'import.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.import'), route('import.index'));
}
);
Breadcrumbs::register(
'import.complete', function (BreadCrumbGenerator $breadcrumbs, ImportJob $job) {
$breadcrumbs->parent('import.index');
$breadcrumbs->push(trans('firefly.bread_crumb_import_complete', ['key' => $job->key]), route('import.complete', [$job->key]));
}
);
Breadcrumbs::register(
'import.configure', function (BreadCrumbGenerator $breadcrumbs, ImportJob $job) {
$breadcrumbs->parent('import.index');
$breadcrumbs->push(trans('firefly.bread_crumb_configure_import', ['key' => $job->key]), route('import.configure', [$job->key]));
}
);
Breadcrumbs::register(
'import.finished', function (BreadCrumbGenerator $breadcrumbs, ImportJob $job) {
$breadcrumbs->parent('import.index');
$breadcrumbs->push(trans('firefly.bread_crumb_import_finished', ['key' => $job->key]), route('import.finished', [$job->key]));
}
);
/**
* PREFERENCES
*/
@ -423,7 +453,6 @@ Breadcrumbs::register(
'preferences.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences.index'));
}
);

View File

@ -934,4 +934,7 @@ return [
'import_finished_link' => 'The transactions imported can be found in tag <a href=":link" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a>.',
'need_at_least_one_account' => 'You need at least one asset account to be able to create piggy banks',
'see_help_top_right' => 'For more information, please check out the help pages using the icon in the top right corner of the page.',
'bread_crumb_import_complete' => 'Import ":key" complete',
'bread_crumb_configure_import' => 'Configure import ":key"',
'bread_crumb_import_finished' => 'Import ":key" finished',
];

View File

@ -1070,6 +1070,97 @@
},
"column-mapping-complete": false
}
},
{
"user_id": 1,
"key": "complete",
"file_type": "csv",
"status": "settings_complete",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
},
{
"user_id": 1,
"key": "configure",
"file_type": "csv",
"status": "import_status_never_started",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
},
{
"user_id": 1,
"key": "settings",
"file_type": "csv",
"status": "import_configuration_saved",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
},
{
"user_id": 1,
"key": "p-settings",
"file_type": "csv",
"status": "import_configuration_saved",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
},
{
"user_id": 1,
"key": "p-configure",
"file_type": "csv",
"status": "import_status_never_started",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
},
{
"user_id": 1,
"key": "finished",
"file_type": "csv",
"status": "import_complete",
"extended_status": {
"steps_done": 0,
"total_steps": 0,
"errors": [],
"import_count": 0,
"importTag": 0
},
"configuration": {
}
}
],
"export-jobs": [

View File

@ -8,6 +8,7 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Import\Setup\CsvSetup;
/**
@ -28,98 +29,97 @@ class ImportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\ImportController::complete
* Implement testComplete().
*/
public function testComplete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.complete', ['complete']));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::configure
* Implement testConfigure().
*/
public function testConfigure()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.configure', ['configure']));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::download
* Implement testDownload().
*/
public function testDownload()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.download', ['configure']));
$this->assertResponseStatus(200);
$this->see('[]');
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::finished
* Implement testFinished().
*/
public function testFinished()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.finished', ['finished']));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::index
* Implement testIndex().
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.index'));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::json
* Implement testJson().
*/
public function testJson()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('import.json', ['configure']));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::postConfigure
* Implement testPostConfigure().
*/
public function testPostConfigure()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$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']);
}
/**
* @covers \FireflyIII\Http\Controllers\ImportController::postSettings
* Implement testPostSettings().
*/
public function testPostSettings()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$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']);
}
/**
@ -128,10 +128,13 @@ class ImportControllerTest extends TestCase
*/
public function testSettings()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$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']);
}
/**
@ -169,12 +172,4 @@ class ImportControllerTest extends TestCase
'This test has not been implemented yet.'
);
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
}