Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 0 additions & 5 deletions .bash_scripts/README.md

This file was deleted.

52 changes: 0 additions & 52 deletions .bash_scripts/clean-all.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=https://billex.local/

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
Expand Down
66 changes: 66 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
APP_NAME=VegaInvoices
APP_ENV=testing
APP_KEY=base64:LBbe25HTnVaJZgxvTSA75A7Im/CqPVSOVWDjxxmIGfs=
APP_DEBUG=true
APP_URL=https://invoice-dev.vegadesign.local
APP_LOCALE=cs
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file

PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12

LOG_CHANNEL=single
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

# TESTOVACÍ DATABÁZE - POZOR! NIKDY NEMĚNIT NA PRODUKČNÍ!
DB_CONNECTION=sqlite
DB_DATABASE=:memory:
# DB_HOST=db
# DB_PORT=3306
# DB_DATABASE=invoice_testing
# DB_USERNAME=invoice
# DB_PASSWORD=VegaInvoice+135

SCOUT_DRIVER=null

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_CONNECTION=sync
SESSION_SECURE_COOKIE=false
SESSION_SAME_SITE=lax
SESSION_DOMAIN=null
SESSION_LIFETIME=480

# REDIS_CLIENT=phpredis
# REDIS_HOST=redis
# REDIS_PASSWORD=null
# REDIS_PORT=6379
REDIS_DB=10
REDIS_CACHE_DB=11
REDIS_SESSION_DB=12
REDIS_PREFIX=testing_

# Speed up FX tests by skipping retry sleep
FX_SKIP_RETRY_SLEEP=true

MAIL_MAILER=array
MAIL_SCHEME=null
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="info@vegaadmin.cz"
MAIL_FROM_NAME="${APP_NAME}"

# GoPay Payment Gateway Configuration
GOPAY_ENABLED=false
GOPAY_GOID=1234567890
GOPAY_CLIENT_ID=9876543210
GOPAY_CLIENT_SECRET=1a2b3c4d
GOPAY_PRODUCTION=false
GOPAY_GATEWAY_URL=https://gw.sandbox.gopay.com/
99 changes: 88 additions & 11 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ We want to have all code in project in English, so all code should be in English

We want to have project as clean as possible. Formulars loads fields from App/Traits trait files. Frontend formulars requests are laoded from App/Requests folder. Backend formulars requests are laoded from App/Requests/Admin folder. Frontend authorization, validation rules, attributes and messages for formulars are placed in App/Requests folder. backend authorization, validation rules, attributes and messages for formulars are placed in App/Requests/Admin folder.

When adding or changing code, always follow the existing code style and structure and look at database to see real state of application.

## Testing Guidelines

### General Testing Guidelines
When creating new tests, always look at similar existing tests in the codebase for inspiration and guidance.

### Backpack Admin Tests Authentication
When creating tests for admin functionality that involve HTTP requests:

Expand All @@ -52,6 +57,51 @@ Route::post('/admin/resource', function (ResourceRequest $request) {

### Testing Strategy Guidelines

#### Database Testing Patterns - CRITICAL RULES
**Choose the correct database refresh pattern based on test type:**

1. **RefreshDatabaseWithData** - Use for Service and Repository tests
- Tests that need **database seeded with basic data** (users, permissions, statuses)
- Service layer tests that interact with real database relationships
- Repository tests that require complex database operations
- **Example Classes**: `UserService`, `ProductService`, `ProductRepository`, `InvoiceService`

2. **RefreshDatabase** - Use for ValueObject and isolated tests
- Tests that can work with **empty database**
- ValueObject tests that only validate business logic
- Unit-style tests within Feature folder that don't need seeded data
- **Example Classes**: `UserPassword`, `ProductPrice`, validation-only tests

```php
// ✅ CORRECT - Service test with seeded data
class UserServiceTest extends TestCase
{
use RefreshDatabaseWithData; // Runs migrations + seeds

public function test_user_creation_with_permissions(): void
{
// Can work with seeded permissions, roles, statuses
}
}

// ✅ CORRECT - ValueObject test with empty database
class UserPasswordTest extends TestCase
{
use RefreshDatabase; // Runs migrations only

public function test_password_validation(): void
{
// Works with empty database, no seeds needed
}
}
```

#### Database Pattern Selection Rules:
- **Services/Repositories** → `RefreshDatabaseWithData` (need seeded data)
- **ValueObjects** → `RefreshDatabase` (work independently)
- **Complex Domain Logic** → `RefreshDatabaseWithData` (need relationships)
- **Simple Validation** → `RefreshDatabase` (isolated testing)

#### For Unit Tests with Mockery (Laravel 12 + Mockery 1.6+)
- **Use string syntax**: `Mockery::mock('App\Models\ClassName')` not arrays or constants
- **Mock Eloquent properties**: Use `shouldReceive('getAttribute')->with('property_name')` for `$model->property` access
Expand Down Expand Up @@ -124,20 +174,20 @@ $returnType = $reflection->getReturnType();
### CRITICAL: Unit Test Execution Rules
- **NEVER use `-v` or `--verbose` options** when running unit tests - these options cause "Unknown option" error
- Use standard `php artisan test` without verbose flags
- **ALL artisan commands must be run in the `vegaadmin-app` docker container**
- Use: `docker exec vegaadmin-app php artisan test ...`
- **ALL artisan commands must be run in the `INVOICE-php-fpm` docker container**
- Use: `docker exec INVOICE-php-fpm php artisan test ...`
- Never run artisan commands directly on host system

### Correct Test Command Examples
```bash
# ✅ Correct
docker exec vegaadmin-app php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php
docker exec vegaadmin-app php artisan test tests/Unit/Http/Requests/Admin/
docker exec vegaadmin-app php artisan test --filter=RequestTest
docker exec INVOICE-php-fpm php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php
docker exec INVOICE-php-fpm php artisan test tests/Unit/Http/Requests/Admin/
docker exec INVOICE-php-fpm php artisan test --filter=RequestTest

# ❌ Wrong - will cause "Unknown option" error
docker exec vegaadmin-app php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php -v
docker exec vegaadmin-app php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php --verbose
docker exec INVOICE-php-fpm php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php -v
docker exec INVOICE-php-fpm php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php --verbose

# ❌ Wrong - missing docker container
php artisan test tests/Unit/Http/Requests/Admin/InvoiceRequestTest.php
Expand Down Expand Up @@ -233,7 +283,34 @@ $this->actingAs($userWithPermission, 'backpack');
- Use `#[Test]` attribute instead of `test` prefix
- Use descriptive method names: `validation_fails_when_name_is_missing()`
- Use `ReflectionClass` instead of `ReflectionMethod`
- Create unique test data with `uniqid()` to avoid conflicts
- **Create unique test data with `uniqid()`** to avoid conflicts with seeded data

### Unique Test Data Pattern (REQUIRED)
When creating test data that might conflict with seeded data, always use unique identifiers:

```php
// ✅ CORRECT - Unique email to avoid conflicts with seeds
public function test_creates_user_with_valid_data(): void
{
$uniqueEmail = 'test_' . uniqid() . '@example.com';
$email = UserEmail::fromString($uniqueEmail);
// ... rest of test
}

// ✅ CORRECT - Unique name to avoid conflicts
public function test_creates_product(): void
{
$uniqueName = 'Test Product ' . uniqid();
$productData = ['name' => $uniqueName];
// ... rest of test
}

// ❌ WRONG - Static data might conflict with seeds
public function test_creates_user(): void
{
$email = UserEmail::fromString('test@example.com'); // Might exist in seeds
}
```

### Request Class Return Types (REQUIRED)
All Request classes must have proper return type annotations:
Expand All @@ -248,8 +325,8 @@ public function messages(): array // or array<string, string>
## 🚨 VERY IMPORTANT: Workspace Path Safety

### CRITICAL RULE: Never Write to Wrong Directories
- **ONLY work within the current workspace**: `/_Data/Dockers/Production/vegaadmin/`
- **NEVER write files to similar-named directories** like `vegalladmin`, `vegladmin`, etc.
- **ONLY work within the current workspace**: `/_Data/Dockers/Production/Invoice/data/www/html/`
- **NEVER write files to similar-named directories
- **ALWAYS double-check file paths** before any write operation
- **Use absolute paths** and verify they start with the correct workspace root
- **If unsure about path, ASK USER** before writing anything
Expand All @@ -260,7 +337,7 @@ public function messages(): array // or array<string, string>
- ❌ `/_Data/Dockers/Production/vegadmin/` (missing 'a')

### Correct Workspace Root:
- ✅ `/_Data/Dockers/Production/vegaadmin/`
- ✅ `/_Data/Dockers/Production/Invoice/data/www/html/`

Writing to wrong directories causes:
- Files not found by tests
Expand Down
12 changes: 6 additions & 6 deletions .github/prompts/clean-build.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Clear Cache and Build Application.

Open terminal and perform next comands:

* cd /_Data/Dockers/Production/vegaadmin
* docker exec vegaadmin-app php artisan cache:clear
* docker exec vegaadmin-app php artisan config:clear
* docker exec vegaadmin-app php artisan view:clear
* docker exec vegaadmin-app php artisan route:clear
* docker exec vegaadmin-app php artisan optimize
* cd /_Data/Dockers/Production/Invoice/data/www/html
* docker exec INVOICE-php-fpm php artisan cache:clear
* docker exec INVOICE-php-fpm php artisan config:clear
* docker exec INVOICE-php-fpm php artisan view:clear
* docker exec INVOICE-php-fpm php artisan route:clear
* docker exec INVOICE-php-fpm php artisan optimize
* npm run build
Loading