mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 22:35:03 +00:00
New tests.
This commit is contained in:
@@ -318,7 +318,8 @@ class ImportController extends Controller
|
||||
{
|
||||
set_time_limit(0);
|
||||
if ($job->status == 'settings_complete') {
|
||||
ImportProcedure::runImport($job);
|
||||
$importProcedure = new ImportProcedure;
|
||||
$importProcedure->runImport($job);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class ImportProcedure
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public static function runImport(ImportJob $job): Collection
|
||||
public function runImport(ImportJob $job): Collection
|
||||
{
|
||||
// update job to say we started.
|
||||
$job->status = 'import_running';
|
||||
|
@@ -292,9 +292,12 @@ class TestData
|
||||
*/
|
||||
private function createImportJobs()
|
||||
{
|
||||
|
||||
$disk = Storage::disk('upload');
|
||||
$insert = [];
|
||||
foreach ($this->data['import-jobs'] as $job) {
|
||||
$insert[] = [
|
||||
$insert[]
|
||||
= [
|
||||
'created_at' => $this->time,
|
||||
'updated_at' => $this->time,
|
||||
'user_id' => $job['user_id'],
|
||||
@@ -304,6 +307,8 @@ class TestData
|
||||
'extended_status' => json_encode($job['extended_status']),
|
||||
'configuration' => json_encode($job['configuration']),
|
||||
];
|
||||
|
||||
$disk->put($job['key'] . '.upload', Crypt::encrypt(''));
|
||||
}
|
||||
DB::table('import_jobs')->insert($insert);
|
||||
}
|
||||
|
@@ -1085,6 +1085,10 @@
|
||||
"importTag": 0
|
||||
},
|
||||
"configuration": {
|
||||
"has-headers": false,
|
||||
"date-format": "Ymd",
|
||||
"delimiter": ",",
|
||||
"import-account": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
|
3
resources/stubs/csv.csv
Normal file
3
resources/stubs/csv.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
Header
|
||||
Value
|
||||
Value
|
|
@@ -9,6 +9,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
use FireflyIII\Import\Setup\CsvSetup;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,7 +125,6 @@ class ImportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::settings
|
||||
* Implement testSettings().
|
||||
*/
|
||||
public function testSettings()
|
||||
{
|
||||
@@ -139,14 +139,12 @@ class ImportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::start
|
||||
* Implement testStart().
|
||||
*/
|
||||
public function testStart()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('post', route('import.start', ['complete']));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,21 +153,20 @@ class ImportControllerTest extends TestCase
|
||||
*/
|
||||
public function testStatus()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
// complete
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('import.status', ['complete']));
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::upload
|
||||
* Implement testUpload().
|
||||
*/
|
||||
public function testUpload()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user