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

+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Tests\Feature;
use App\Models\ApplicationInstallation;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class InstallationTest extends TestCase
{
use RefreshDatabase;
public function test_a_clean_database_can_be_installed_once(): void
{
$this->get('/install')->assertOk()->assertSee('Create your business');
$response = $this->post('/install', [
'businessName' => 'Installed Shop',
'slug' => 'installed-shop',
'domain' => 'localhost',
'adminName' => 'First Owner',
'adminEmail' => 'first-owner@example.test',
'password' => 'password123',
'password_confirmation' => 'password123',
]);
$response->assertRedirect(route('install'));
$this->assertDatabaseHas('ApplicationInstallation', ['id' => 'singleton', 'status' => 'INSTALLED']);
$this->assertDatabaseHas('Business', ['slug' => 'installed-shop']);
$this->assertDatabaseHas('User', ['email' => 'first-owner@example.test']);
$this->get('/install')->assertRedirect(route('public.home'));
$this->assertSame(1, ApplicationInstallation::count());
}
}
+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());
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}