mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 20:22:15 +01:00
Add harvest and generic imports
This commit is contained in:
committed by
Constantin Graf
parent
9faa8fe6e1
commit
f93c5370bf
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Service\Import\Importers;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Organization;
|
||||
use App\Service\Import\Importers\DefaultImporter;
|
||||
use App\Service\Import\Importers\HarvestClientsImporter;
|
||||
use App\Service\Import\Importers\ImportException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
|
||||
#[CoversClass(HarvestClientsImporter::class)]
|
||||
#[CoversClass(ImportException::class)]
|
||||
#[CoversClass(DefaultImporter::class)]
|
||||
#[UsesClass(HarvestClientsImporter::class)]
|
||||
class HarvestClientsImporterTest extends ImporterTestAbstract
|
||||
{
|
||||
public function test_import_of_test_file_succeeds(): void
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new HarvestClientsImporter;
|
||||
$importer->init($organization);
|
||||
$data = Storage::disk('testfiles')->get('harvest_clients_import_test_1.csv');
|
||||
|
||||
// Act
|
||||
$importer->importData($data, $timezone);
|
||||
|
||||
// Assert
|
||||
$clients = Client::query()->whereBelongsTo($organization, 'organization')->get();
|
||||
$this->assertCount(2, $clients);
|
||||
$client1 = $clients->where('name', 'Example Client')->first();
|
||||
$this->assertNotNull($client1);
|
||||
// Client name in Harvest: \\ 🔥 Special characters """`!@#$%^&*()_+\-=\[\]{};':"\\|,.''<>\/?~ \\\
|
||||
$client2 = $clients->where('name', '\\\\ 🔥 Special characters """`!@#$%^&*()_+\-=\[\]{};\':"\\\\|,.\'\'<>\/?~ \\\\\\')->first();
|
||||
$this->assertNotNull($client2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user