JsonImporterServiceTest.php
1 <?php 2 3 namespace Tests\Services; 4 5 use App\Http\Services\JsonImporterService; 6 use App\Models\Dossier; 7 use App\Models\Template; 8 use App\Models\ValidationType; 9 use Exception; 10 use Illuminate\Support\Facades\DB; 11 use Illuminate\Support\Facades\Storage; 12 use Tests\TestCase; 13 14 class JsonImporterServiceTest extends TestCase 15 { 16 const zip = 'test_files/2022-02-28_2022-04_json.zip'; 17 const json = 'test_files/2022-02-28_2022-04_json/evalinfo.json'; 18 19 /** 20 * @throws Exception 21 */ 22 public function test_zip_import() 23 { 24 JsonImporterService::import(Storage::path(self::zip)); 25 26 //check if the 9 files of the zip are saved 27 $this->assertEquals(11, DB::table('json_drafts')->count()); 28 } 29 30 /** 31 * @throws Exception 32 */ 33 public function test_read_json_from_file() 34 { 35 JsonImporterService::createJsonDraftFromPath(Storage::path(self::json)); 36 37 // if no exception given, execution is fine 38 $this->assertDatabaseCount('json_drafts', 1); 39 } 40 }