mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Moved import test files; Added timezone argument to importers
This commit is contained in:
committed by
Constantin Graf
parent
7af77c9357
commit
b5a240cb2f
@@ -19,11 +19,12 @@ class ImportServiceTest extends TestCase
|
||||
// Arrange
|
||||
Storage::fake(config('filesystems.default'));
|
||||
$organization = Organization::factory()->create();
|
||||
$data = file_get_contents(storage_path('tests/toggl_time_entries_import_test_1.csv'));
|
||||
$timezone = 'Europe/Vienna';
|
||||
$data = Storage::disk('testfiles')->get('toggl_time_entries_import_test_1.csv');
|
||||
|
||||
// Act
|
||||
$importService = app(ImportService::class);
|
||||
$report = $importService->import($organization, 'toggl_time_entries', $data);
|
||||
$report = $importService->import($organization, 'toggl_time_entries', $data, $timezone);
|
||||
|
||||
// Assert
|
||||
$this->assertSame(2, $report->timeEntriesCreated);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Tests\Unit\Service\Import\Importer;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Service\Import\Importers\ClockifyProjectsImporter;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ClockifyProjectsImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
@@ -13,12 +14,13 @@ class ClockifyProjectsImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new ClockifyProjectsImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/clockify_projects_import_test_1.csv'));
|
||||
$data = Storage::disk('testfiles')->get('clockify_projects_import_test_1.csv');
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
|
||||
// Assert
|
||||
$this->checkTestScenarioProjectsOnlyAfterImport();
|
||||
@@ -28,15 +30,16 @@ class ClockifyProjectsImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new ClockifyProjectsImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/clockify_projects_import_test_1.csv'));
|
||||
$importer->importData($data);
|
||||
$data = Storage::disk('testfiles')->get('clockify_projects_import_test_1.csv');
|
||||
$importer->importData($data, $timezone);
|
||||
$importer = new ClockifyProjectsImporter();
|
||||
$importer->init($organization);
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
|
||||
// Assert
|
||||
$this->checkTestScenarioProjectsOnlyAfterImport();
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Tests\Unit\Service\Import\Importer;
|
||||
use App\Models\Organization;
|
||||
use App\Models\TimeEntry;
|
||||
use App\Service\Import\Importers\ClockifyTimeEntriesImporter;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ClockifyTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
@@ -14,12 +15,13 @@ class ClockifyTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new ClockifyTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/clockify_time_entries_import_test_1.csv'));
|
||||
$data = Storage::disk('testfiles')->get('clockify_time_entries_import_test_1.csv');
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
|
||||
// Assert
|
||||
$testScenario = $this->checkTestScenarioAfterImportExcludingTimeEntries();
|
||||
@@ -45,15 +47,16 @@ class ClockifyTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new ClockifyTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/clockify_time_entries_import_test_1.csv'));
|
||||
$importer->importData($data);
|
||||
$data = Storage::disk('testfiles')->get('clockify_time_entries_import_test_1.csv');
|
||||
$importer->importData($data, $timezone);
|
||||
$importer = new ClockifyTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
|
||||
// Assert
|
||||
$testScenario = $this->checkTestScenarioAfterImportExcludingTimeEntries();
|
||||
|
||||
@@ -33,12 +33,13 @@ class TogglDataImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new TogglDataImporter();
|
||||
$importer->init($organization);
|
||||
|
||||
// Act
|
||||
try {
|
||||
$importer->importData('not a zip');
|
||||
$importer->importData('not a zip', $timezone);
|
||||
} catch (Exception $e) {
|
||||
$this->assertInstanceOf(ImportException::class, $e);
|
||||
$this->assertSame('Invalid ZIP, error code: 19', $e->getMessage());
|
||||
@@ -52,13 +53,14 @@ class TogglDataImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$zipPath = $this->createTestZip('toggl_data_import_test_1');
|
||||
$timezone = 'Europe/Vienna';
|
||||
$organization = Organization::factory()->create();
|
||||
$importer = new TogglDataImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents($zipPath);
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
$report = $importer->getReport();
|
||||
|
||||
// Assert
|
||||
@@ -75,16 +77,17 @@ class TogglDataImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$zipPath = $this->createTestZip('toggl_data_import_test_1');
|
||||
$timezone = 'Europe/Vienna';
|
||||
$organization = Organization::factory()->create();
|
||||
$importer = new TogglDataImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents($zipPath);
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
$importer = new TogglDataImporter();
|
||||
$importer->init($organization);
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
$report = $importer->getReport();
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Tests\Unit\Service\Import\Importer;
|
||||
use App\Models\Organization;
|
||||
use App\Models\TimeEntry;
|
||||
use App\Service\Import\Importers\TogglTimeEntriesImporter;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TogglTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
@@ -14,12 +15,13 @@ class TogglTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new TogglTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/toggl_time_entries_import_test_1.csv'));
|
||||
$data = Storage::disk('testfiles')->get('toggl_time_entries_import_test_1.csv');
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
$report = $importer->getReport();
|
||||
|
||||
// Assert
|
||||
@@ -52,15 +54,16 @@ class TogglTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new TogglTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
$data = file_get_contents(storage_path('tests/toggl_time_entries_import_test_1.csv'));
|
||||
$importer->importData($data, []);
|
||||
$data = Storage::disk('testfiles')->get('toggl_time_entries_import_test_1.csv');
|
||||
$importer->importData($data, $timezone);
|
||||
$importer = new TogglTimeEntriesImporter();
|
||||
$importer->init($organization);
|
||||
|
||||
// Act
|
||||
$importer->importData($data);
|
||||
$importer->importData($data, $timezone);
|
||||
$report = $importer->getReport();
|
||||
|
||||
// Assert
|
||||
|
||||
Reference in New Issue
Block a user