Permalink
Browse files

Add database test for import model

Refs #2446
  • Loading branch information...
1 parent 6173ff1 commit e45dc9601c5a796816137b4a4212873376d48af6 @daftspunk daftspunk committed Nov 2, 2016
@@ -0,0 +1 @@
+File one contents
@@ -0,0 +1 @@
+FILE TWO CONTENTS
@@ -0,0 +1,40 @@
+<?php
+
+use Backend\Models\ImportModel;
+use System\Models\File as FileModel;
+
+class ExampleDbImportModel extends ImportModel
+{
+ public $rules = [];
+
+ public function importData($results, $sessionKey = null)
+ {
+ return [];
+ }
+}
+
+class ImportModelDbTest extends PluginTestCase
+{
+ public function testGetImportFilePath()
+ {
+ $model = new ExampleDbImportModel;
+ $sessionKey = uniqid('session_key', true);
+
+ $file1 = FileModel::create([
+ 'data' => base_path().'/tests/fixtures/backend/reference/file1.txt'
+ ]);
+
+ $file2 = FileModel::create([
+ 'data' => base_path().'/tests/fixtures/backend/reference/file2.txt'
+ ]);
+
+ $model->import_file()->add($file1, $sessionKey);
+ $model->import_file()->add($file2, $sessionKey);
+
+ $this->assertEquals(
+ $file2->getLocalPath(),
+ $model->getImportFilePath($sessionKey),
+ 'ImportModel::getImportFilePath() should return the last uploaded file.'
+ );
+ }
+}

0 comments on commit e45dc96

Please sign in to comment.