mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-12 15:53:19 +01:00
Updated Laravel to v13
This commit is contained in:
committed by
Constantin Graf
parent
12cc3f27f8
commit
2dadf1ef02
@@ -8,6 +8,7 @@ use Closure;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
use Mockery;
|
||||
use Tests\TestCaseWithDatabase;
|
||||
|
||||
class ApiEndpointTestAbstract extends TestCaseWithDatabase
|
||||
@@ -21,21 +22,23 @@ class ApiEndpointTestAbstract extends TestCaseWithDatabase
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the temporary URL builder of the private disk to capture the options
|
||||
* passed to temporaryUrl. Returns a closure that yields the captured options.
|
||||
* Captures the options passed to temporaryUrl on the private disk.
|
||||
*
|
||||
* @return Closure(): (array<string, mixed>|null)
|
||||
*/
|
||||
protected function captureTemporaryUrlOptions(): Closure
|
||||
{
|
||||
$captured = null;
|
||||
Storage::disk(config('filesystems.private'))->buildTemporaryUrlsUsing(
|
||||
$diskName = config('filesystems.private');
|
||||
$disk = Mockery::mock(Storage::disk($diskName))->makePartial();
|
||||
$disk->shouldReceive('temporaryUrl')->andReturnUsing(
|
||||
function (string $path, DateTimeInterface $expiration, array $options) use (&$captured): string {
|
||||
$captured = $options;
|
||||
|
||||
return 'https://storage.fake/'.$path;
|
||||
}
|
||||
);
|
||||
Storage::set($diskName, $disk);
|
||||
|
||||
return function () use (&$captured): ?array {
|
||||
return $captured;
|
||||
|
||||
@@ -544,6 +544,68 @@ class OrganizationResourceTest extends FilamentTestCase
|
||||
$this->assertSame(Role::Owner->value, $ownerMember->refresh()->role);
|
||||
}
|
||||
|
||||
public function test_edit_related_user_does_not_change_role_if_role_is_unchanged_for_owner(): void
|
||||
{
|
||||
// Arrange
|
||||
$owner = User::factory()->create();
|
||||
$organization = Organization::factory()->withOwner($owner)->create();
|
||||
$ownerMember = Member::factory()->forOrganization($organization)->forUser($owner)->role(Role::Owner)->billableRate(1000)->create();
|
||||
|
||||
// Act
|
||||
$response = Livewire::test(OrganizationResource\RelationManagers\UsersRelationManager::class, [
|
||||
'ownerRecord' => $organization,
|
||||
'pageClass' => OrganizationResource\Pages\EditOrganization::class,
|
||||
])->callTableAction('edit', $owner, data: [
|
||||
'role' => Role::Owner->value,
|
||||
'billable_rate' => 2000,
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertSuccessful();
|
||||
$response->assertHasNoTableActionErrors();
|
||||
$response->assertNotNotified(
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Update failed')
|
||||
->body(__('exceptions.api.organization_needs_at_least_one_owner'))
|
||||
->persistent()
|
||||
);
|
||||
$ownerMember->refresh();
|
||||
$this->assertSame(Role::Owner->value, $ownerMember->role);
|
||||
$this->assertSame(2000, $ownerMember->billable_rate);
|
||||
}
|
||||
|
||||
public function test_edit_related_user_does_not_change_role_if_role_is_unchanged_for_placeholder(): void
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$user = User::factory()->placeholder()->create();
|
||||
$member = Member::factory()->forOrganization($organization)->forUser($user)->role(Role::Placeholder)->billableRate(1000)->create();
|
||||
|
||||
// Act
|
||||
$response = Livewire::test(OrganizationResource\RelationManagers\UsersRelationManager::class, [
|
||||
'ownerRecord' => $organization,
|
||||
'pageClass' => OrganizationResource\Pages\EditOrganization::class,
|
||||
])->callTableAction('edit', $user, data: [
|
||||
'role' => Role::Placeholder->value,
|
||||
'billable_rate' => 2000,
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertSuccessful();
|
||||
$response->assertHasNoTableActionErrors();
|
||||
$response->assertNotNotified(
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Update failed')
|
||||
->body(__('exceptions.api.changing_role_of_placeholder_is_not_allowed'))
|
||||
->persistent()
|
||||
);
|
||||
$member->refresh();
|
||||
$this->assertSame(Role::Placeholder->value, $member->role);
|
||||
$this->assertSame(2000, $member->billable_rate);
|
||||
}
|
||||
|
||||
public function test_can_detach_related_user_from_organization(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -286,6 +286,62 @@ class UserResourceTest extends FilamentTestCase
|
||||
$this->assertSame(Role::Owner->value, $ownerMember->refresh()->role);
|
||||
}
|
||||
|
||||
public function test_edit_related_organization_does_not_change_role_if_role_is_unchanged_for_owner(): void
|
||||
{
|
||||
// Arrange
|
||||
$owner = User::factory()->create();
|
||||
$organization = Organization::factory()->withOwner($owner)->create();
|
||||
$ownerMember = Member::factory()->forOrganization($organization)->forUser($owner)->role(Role::Owner)->create();
|
||||
|
||||
// Act
|
||||
$response = Livewire::test(UserResource\RelationManagers\OrganizationsRelationManager::class, [
|
||||
'ownerRecord' => $owner,
|
||||
'pageClass' => UserResource\Pages\EditUser::class,
|
||||
])->callTableAction('edit', $organization, data: [
|
||||
'role' => Role::Owner->value,
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertSuccessful();
|
||||
$response->assertHasNoTableActionErrors();
|
||||
$response->assertNotNotified(
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Update failed')
|
||||
->body(__('exceptions.api.organization_needs_at_least_one_owner'))
|
||||
->persistent()
|
||||
);
|
||||
$this->assertSame(Role::Owner->value, $ownerMember->refresh()->role);
|
||||
}
|
||||
|
||||
public function test_edit_related_organization_does_not_change_role_if_role_is_unchanged_for_placeholder(): void
|
||||
{
|
||||
// Arrange
|
||||
$user = User::factory()->placeholder()->create();
|
||||
$organization = Organization::factory()->create();
|
||||
$member = Member::factory()->forOrganization($organization)->forUser($user)->role(Role::Placeholder)->create();
|
||||
|
||||
// Act
|
||||
$response = Livewire::test(UserResource\RelationManagers\OrganizationsRelationManager::class, [
|
||||
'ownerRecord' => $user,
|
||||
'pageClass' => UserResource\Pages\EditUser::class,
|
||||
])->callTableAction('edit', $organization, data: [
|
||||
'role' => Role::Placeholder->value,
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertSuccessful();
|
||||
$response->assertHasNoTableActionErrors();
|
||||
$response->assertNotNotified(
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Update failed')
|
||||
->body(__('exceptions.api.changing_role_of_placeholder_is_not_allowed'))
|
||||
->persistent()
|
||||
);
|
||||
$this->assertSame(Role::Placeholder->value, $member->refresh()->role);
|
||||
}
|
||||
|
||||
public function test_can_detach_related_organization_from_user(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -187,7 +187,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::SymbolAfterWithSpace);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
@@ -201,7 +201,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::SymbolBeforeWithSpace);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
@@ -215,7 +215,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::SymbolBefore);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
@@ -229,7 +229,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::SymbolAfter);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
@@ -243,7 +243,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::ISOCodeAfterWithSpace);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
@@ -257,7 +257,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
|
||||
// Arrange
|
||||
$this->localizationService->setCurrencyFormat(CurrencyFormat::ISOCodeBeforeWithSpace);
|
||||
$this->localizationService->setNumberFormat(NumberFormat::ThousandsSpaceDecimalComma);
|
||||
$money = Money::of(1234567.89, Currency::of('EUR'));
|
||||
$money = Money::of('1234567.89', Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$formatted = $this->localizationService->formatCurrency($money);
|
||||
|
||||
Reference in New Issue
Block a user