|
- {{ trans.methods.__("models.classes.claimsubjects") }}
+ {{ claimsubjectLabel }}
|
{{ selectParameters.subject?.label }}
@@ -301,7 +301,8 @@ const selectParameters = reactive<{
// * COMPUTED
const isUsedWithProps = computed(() => attrs.json === undefined);
-const brandLabel = computed(() => trans.methods.__("models.classes.brands").toString().replace(/s$/, ""));
+const brandLabel = computed(() => trans.methods.__("models.classes.brands").toString().toLowerCase().replace(/s$/, ""));
+const claimsubjectLabel = computed(() => trans.methods.__("models.classes.claimsubjects").toLowerCase().toString().replace(/s$/, ""));
const isTreatedClaim = computed(() => Object.values(enumParameters.claimStatus).find(e => e.name === "treated")?.value == selectParameters.enums["status"]);
// * LIFECYCLE
diff --git a/resources/views/bo/pages/claims/index-list.blade.php b/resources/views/bo/pages/claims/index-list.blade.php
index a1e7d6b..a792a74 100644
--- a/resources/views/bo/pages/claims/index-list.blade.php
+++ b/resources/views/bo/pages/claims/index-list.blade.php
@@ -40,8 +40,8 @@
@can('preview', $claimModel)
{{-- PREVIEW TRIGGER MODAL --}}
@endcan
diff --git a/tests/CRM/ApiV4/ClaimTest.php b/tests/CRM/ApiV4/ClaimTest.php
index f17e97c..431aee9 100644
--- a/tests/CRM/ApiV4/ClaimTest.php
+++ b/tests/CRM/ApiV4/ClaimTest.php
@@ -24,6 +24,7 @@ class ClaimTest extends ApiBase
{
parent::setUp();
+ $image = UploadedFile::fake()->image('photo.jpg');
$this->skeleton = [
'first_name' => 'Jean',
'last_name' => 'Bond',
@@ -32,7 +33,7 @@ class ClaimTest extends ApiBase
'address' => '10 rue des totos',
'city' => 'Le Mans',
'postcode' => '72100',
- 'file' => UploadedFile::fake()->image('photo.jpg'),
+ 'file' => base64_encode(file_get_contents($image->getRealPath())),
];
}
@@ -132,10 +133,13 @@ class ClaimTest extends ApiBase
$subject = ClaimSubject::query()->firstOrNew();
$customer = Customer::query()->firstOrNew();
+ // Create fake .gif base64.
+ $base64Gif = 'R0lGODlhAQABAIAAAAUEBA==';
+
$response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge(
Arr::except($this->skeleton, ['address', 'city', 'postcode', 'file']),
[
- 'file' => \Illuminate\Http\UploadedFile::fake()->create('x.gif', 100, 'image/gif'),
+ 'file' => $base64Gif,
'brand_id' => $brand->getKey(),
'subject_id' => $subject->getKey(),
'customer_id' => $customer->getKey(),
diff --git a/tests/Client/CrmClientClaimTest.php b/tests/Client/CrmClientClaimTest.php
new file mode 100644
index 0000000..d8308e5
--- /dev/null
+++ b/tests/Client/CrmClientClaimTest.php
@@ -0,0 +1,71 @@
+image('photo.jpg');
+ $this->assertTrue(Claim::setClaim(
+ 'Jean',
+ 'Bond',
+ 'claim@hotmail.fr',
+ 'Ceci est un message.',
+ 1,
+ 1,
+ '10 rue des totos',
+ 'Le Mans',
+ '72100',
+ base64_encode(file_get_contents($image->getRealPath())),
+ ));
+ $this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists());
+ }
+
+ /**
+ * Create new claim without optionnal fields.
+ *
+ * @return void
+ */
+ public function testCreateClaimWithoutOptionnalFields(): void
+ {
+ $this->assertTrue(Claim::setClaim(
+ 'Jean',
+ 'Bond',
+ 'claim@hotmail.fr',
+ 'Ceci est un message.',
+ 1,
+ 1,
+ ));
+ $this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists());
+ }
+
+ /**
+ * Create new claim should fail.
+ *
+ * @return void
+ */
+ public function testCreateClaimShouldFail(): void
+ {
+ $this->expectException(ValidationException::class);
+ Claim::setClaim(
+ 'Jean',
+ 'Bond',
+ 'claim@hotmail.fr',
+ 'Ceci est un message.',
+ 0,
+ 0,
+ );
+ $this->assertSame(0, ModelsClaim::count());
+ }
+}
|