mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-15 01:03:16 +01:00
Add tests for billable rate restriction in importers and API edge cases
This commit is contained in:
committed by
Gregor Vostrak
parent
902270a189
commit
c69edc81be
@@ -7,6 +7,7 @@ namespace Tests\Unit\Service\Import\Importers;
|
||||
use App\Enums\TimeEntryType;
|
||||
use App\Jobs\RecalculateSpentTimeForProject;
|
||||
use App\Jobs\RecalculateSpentTimeForTask;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectMember;
|
||||
@@ -111,6 +112,13 @@ class SolidtimeImporterTest extends ImporterTestAbstract
|
||||
// Arrange
|
||||
$this->actAsOrganizationWithoutBillableRates();
|
||||
$zipPath = $this->createTestZip('solidtime_import_test_1');
|
||||
// Note: The member of the test file has no billable rate, so one is added to the zip
|
||||
$zip = new ZipArchive;
|
||||
$zip->open($zipPath);
|
||||
$members = str_replace(',ee5a8cd6-312f-4ae6-b044-e2014f09ecc2,,admin,', ',ee5a8cd6-312f-4ae6-b044-e2014f09ecc2,10003,admin,', $zip->getFromName('members.csv'), $replacements);
|
||||
$this->assertSame(1, $replacements);
|
||||
$zip->addFromString('members.csv', $members);
|
||||
$zip->close();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$organization = Organization::factory()->create();
|
||||
$importer = new SolidtimeImporter;
|
||||
@@ -127,6 +135,9 @@ class SolidtimeImporterTest extends ImporterTestAbstract
|
||||
// Assert
|
||||
$this->assertSame(3, Project::query()->whereBelongsTo($organization, 'organization')->whereNull('billable_rate')->where('is_billable', '=', false)->count());
|
||||
$this->assertSame(1, ProjectMember::query()->whereBelongsToOrganization($organization)->whereNull('billable_rate')->count());
|
||||
$members = Member::query()->whereBelongsTo($organization, 'organization')->get();
|
||||
$this->assertCount(1, $members);
|
||||
$this->assertNull($members->first()->billable_rate);
|
||||
$timeEntries = TimeEntry::query()->whereBelongsTo($organization, 'organization')->get();
|
||||
$this->assertCount(2, $timeEntries);
|
||||
foreach ($timeEntries as $timeEntry) {
|
||||
|
||||
Reference in New Issue
Block a user