mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 08:12:17 +01:00
Fix bug in time-entry.update-multiple; Add computed property for client_id
This commit is contained in:
committed by
Constantin Graf
parent
b3b84db004
commit
d5a4df738f
@@ -148,4 +148,35 @@ class TimeEntryModelTest extends ModelTestAbstract
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertTrue($result->first()->is($timeEntry1));
|
||||
}
|
||||
|
||||
public function test_computed_client_id_returns_null_when_no_project_is_assigned(): void
|
||||
{
|
||||
// Arrange
|
||||
$timeEntry = TimeEntry::factory()->forProject(null)->create();
|
||||
$timeEntry->client_id = null;
|
||||
$timeEntry->save();
|
||||
|
||||
// Act
|
||||
$timeEntry->setComputedAttributeValue('client_id');
|
||||
$clientId = $timeEntry->client_id;
|
||||
|
||||
// Assert
|
||||
$this->assertNull($clientId);
|
||||
}
|
||||
|
||||
public function test_computed_client_id_returns_project_client_id(): void
|
||||
{
|
||||
// Arrange
|
||||
$project = Project::factory()->create();
|
||||
$timeEntry = TimeEntry::factory()->forProject($project)->create();
|
||||
$timeEntry->client_id = null;
|
||||
$timeEntry->save();
|
||||
|
||||
// Act
|
||||
$timeEntry->setComputedAttributeValue('client_id');
|
||||
$clientId = $timeEntry->client_id;
|
||||
|
||||
// Assert
|
||||
$this->assertSame($project->client_id, $clientId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user