PHP Rebuild
CI / ci (push) Canceled after 0s

Initial PHP rebuild of the app
This commit is contained in:
Stefan Lazic committed 2026-09-05 08:21:33 +01:00
1 parent 8a2b211069
commit 2ef3654841
690 files changed
+33944 -12046

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
<?php
namespace Tests\Feature;
use App\Models\Business;
use App\Models\BusinessDomain;
use App\Models\CustomerProfile;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class TenantAndAuthTest extends TestCase
{
use RefreshDatabase;
public function test_the_host_selects_only_its_business(): void
{
$this->seed();
$other = Business::create([
'slug' => 'other-barbershop',
'name' => 'Other Barbershop',
'timezone' => 'Europe/London',
'currency' => 'GBP',
'locale' => 'en-GB',
]);
BusinessDomain::create([
'businessId' => $other->id,
'hostname' => 'other.test',
'isPrimary' => true,
'isActive' => true,
]);
$this->get('http://localhost/')
->assertOk()
->assertSee('Blake Heritage Barbershop')
->assertSee('Classic Haircut')
->assertDontSeeText('Other Barbershop');
$this->get('http://other.test/')
->assertOk()
->assertSee('Other Barbershop')
->assertDontSeeText('Classic Haircut');
}
public function test_registration_creates_a_customer_profile_in_the_current_tenant(): void
{
$this->seed();
$response = $this->withHeaders(['Host' => 'localhost'])
->post('/register', [
'firstName' => 'Taylor',
'lastName' => 'Member',
'email' => 'taylor@example.test',
'phone' => '020 7000 0000',
'password' => 'password123',
'password_confirmation' => 'password123',
]);
$response->assertRedirect(route('customer.dashboard'));
$this->assertAuthenticated();
$this->assertDatabaseHas('User', ['email' => 'taylor@example.test']);
$this->assertDatabaseHas('CustomerProfile', [
'email' => 'taylor@example.test',
'isGuest' => 0,
'businessId' => Business::where('slug', 'demo-barbershop')->value('id'),
]);
$this->assertSame(1, CustomerProfile::where('email', 'taylor@example.test')->count());
$this->withHeaders(['Host' => 'localhost'])->get('/account')->assertOk()->assertSee('Good to see you, Taylor');
$this->withHeaders(['Host' => 'localhost'])->get('/owner')->assertForbidden();
$this->assertNotNull(User::where('email', 'taylor@example.test')->first());
}
}