Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/DiscountsTest.php
Show All 36 Lines | public function testuserDiscounts(): void | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Admin user | // Admin user | ||||
$response = $this->actingAs($admin)->get("api/v4/users/{$user->id}/discounts"); | $response = $this->actingAs($admin)->get("api/v4/users/{$user->id}/discounts"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$discount_test = Discount::where('code', 'TEST')->first(); | $discount_test = Discount::withObjectTenantContext($user)->where('code', 'TEST')->first(); | ||||
$discount_free = Discount::where('discount', 100)->first(); | $discount_free = Discount::withObjectTenantContext($user)->where('discount', 100)->first(); | ||||
$this->assertSame(3, $json['count']); | $this->assertSame(3, $json['count']); | ||||
$this->assertSame($discount_test->id, $json['list'][0]['id']); | $this->assertSame($discount_test->id, $json['list'][0]['id']); | ||||
$this->assertSame($discount_test->discount, $json['list'][0]['discount']); | $this->assertSame($discount_test->discount, $json['list'][0]['discount']); | ||||
$this->assertSame($discount_test->code, $json['list'][0]['code']); | $this->assertSame($discount_test->code, $json['list'][0]['code']); | ||||
$this->assertSame($discount_test->description, $json['list'][0]['description']); | $this->assertSame($discount_test->description, $json['list'][0]['description']); | ||||
$this->assertSame('10% - Test voucher [TEST]', $json['list'][0]['label']); | $this->assertSame('10% - Test voucher [TEST]', $json['list'][0]['label']); | ||||
Show All 23 Lines |