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);
|
set_time_limit(0);
|
||||||
if ($job->status == 'settings_complete') {
|
if ($job->status == 'settings_complete') {
|
||||||
ImportProcedure::runImport($job);
|
$importProcedure = new ImportProcedure;
|
||||||
|
$importProcedure->runImport($job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ class ImportProcedure
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public static function runImport(ImportJob $job): Collection
|
public function runImport(ImportJob $job): Collection
|
||||||
{
|
{
|
||||||
// update job to say we started.
|
// update job to say we started.
|
||||||
$job->status = 'import_running';
|
$job->status = 'import_running';
|
||||||
|
@@ -292,9 +292,12 @@ class TestData
|
|||||||
*/
|
*/
|
||||||
private function createImportJobs()
|
private function createImportJobs()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$disk = Storage::disk('upload');
|
||||||
$insert = [];
|
$insert = [];
|
||||||
foreach ($this->data['import-jobs'] as $job) {
|
foreach ($this->data['import-jobs'] as $job) {
|
||||||
$insert[] = [
|
$insert[]
|
||||||
|
= [
|
||||||
'created_at' => $this->time,
|
'created_at' => $this->time,
|
||||||
'updated_at' => $this->time,
|
'updated_at' => $this->time,
|
||||||
'user_id' => $job['user_id'],
|
'user_id' => $job['user_id'],
|
||||||
@@ -304,6 +307,8 @@ class TestData
|
|||||||
'extended_status' => json_encode($job['extended_status']),
|
'extended_status' => json_encode($job['extended_status']),
|
||||||
'configuration' => json_encode($job['configuration']),
|
'configuration' => json_encode($job['configuration']),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$disk->put($job['key'] . '.upload', Crypt::encrypt(''));
|
||||||
}
|
}
|
||||||
DB::table('import_jobs')->insert($insert);
|
DB::table('import_jobs')->insert($insert);
|
||||||
}
|
}
|
||||||
|
@@ -1085,6 +1085,10 @@
|
|||||||
"importTag": 0
|
"importTag": 0
|
||||||
},
|
},
|
||||||
"configuration": {
|
"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.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
use FireflyIII\Import\Setup\CsvSetup;
|
use FireflyIII\Import\Setup\CsvSetup;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,7 +125,6 @@ class ImportControllerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\ImportController::settings
|
* @covers \FireflyIII\Http\Controllers\ImportController::settings
|
||||||
* Implement testSettings().
|
|
||||||
*/
|
*/
|
||||||
public function testSettings()
|
public function testSettings()
|
||||||
{
|
{
|
||||||
@@ -139,14 +139,12 @@ class ImportControllerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\ImportController::start
|
* @covers \FireflyIII\Http\Controllers\ImportController::start
|
||||||
* Implement testStart().
|
|
||||||
*/
|
*/
|
||||||
public function testStart()
|
public function testStart()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->be($this->user());
|
||||||
$this->markTestIncomplete(
|
$this->call('post', route('import.start', ['complete']));
|
||||||
'This test has not been implemented yet.'
|
$this->assertResponseStatus(200);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,21 +153,20 @@ class ImportControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testStatus()
|
public function testStatus()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
// complete
|
||||||
$this->markTestIncomplete(
|
$this->be($this->user());
|
||||||
'This test has not been implemented yet.'
|
$this->call('get', route('import.status', ['complete']));
|
||||||
);
|
$this->assertResponseStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\ImportController::upload
|
* @covers \FireflyIII\Http\Controllers\ImportController::upload
|
||||||
* Implement testUpload().
|
|
||||||
*/
|
*/
|
||||||
public function testUpload()
|
public function testUpload()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$path = resource_path('stubs/csv.csv');
|
||||||
$this->markTestIncomplete(
|
$file = new UploadedFile($path, 'upload.csv', filesize($path), 'text/csv', null, true);
|
||||||
'This test has not been implemented yet.'
|
$this->call('POST', route('import.upload'), [], [], ['import_file' => $file], ['Accept' => 'application/json']);
|
||||||
);
|
$this->assertResponseStatus(302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user