From 101cdb5d10d9abbb3a7bc5cc973388f66d997e38 Mon Sep 17 00:00:00 2001 From: lubiana Date: Wed, 21 May 2025 21:43:53 +0200 Subject: [PATCH] junijunijuni --- .forgejo/workflows/pull_request.yml | 9 ++- .forgejo/workflows/push.yml | 9 ++- .forgejo/workflows/release.yml | 11 +-- .junie/guidelines.md | 111 ++++++++++++++++++++++++++++ tests/Unit/Service/FaviconTest.php | 20 +++++ 5 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 .junie/guidelines.md create mode 100644 tests/Unit/Service/FaviconTest.php diff --git a/.forgejo/workflows/pull_request.yml b/.forgejo/workflows/pull_request.yml index 6bbc920..599185d 100644 --- a/.forgejo/workflows/pull_request.yml +++ b/.forgejo/workflows/pull_request.yml @@ -3,8 +3,13 @@ jobs: ls: runs-on: docker container: - image: git.php.fail/lubiana/container/php:8.4.1-ci + image: php:8.4-cli steps: + - name: Install dependencies + run: | + apt-get update + apt-get install -y git + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - name: Manually checkout env: REPO: '${{ github.repository }}' @@ -34,4 +39,4 @@ jobs: git config --global user.email "gitbot@users.noreply.php.fail" git commit -am "${{ env.CI_COMMIT_MESSAGE }}" git push - fi \ No newline at end of file + fi diff --git a/.forgejo/workflows/push.yml b/.forgejo/workflows/push.yml index b4a5837..b0cd875 100644 --- a/.forgejo/workflows/push.yml +++ b/.forgejo/workflows/push.yml @@ -6,8 +6,13 @@ jobs: ls: runs-on: docker container: - image: git.php.fail/lubiana/container/php:8.4.1-ci + image: php:8.4-cli steps: + - name: Install dependencies + run: | + apt-get update + apt-get install -y git + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - name: Manually checkout env: REPO: '${{ github.repository }}' @@ -38,4 +43,4 @@ jobs: git config --global user.email "gitbot@users.noreply.php.fail" git commit -am "${{ env.CI_COMMIT_MESSAGE }}" git push - fi \ No newline at end of file + fi diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index d036f12..a321200 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -4,8 +4,13 @@ jobs: ls: runs-on: docker container: - image: git.php.fail/lubiana/container/php:8.4.1-ci + image: php:8.4-cli steps: + - name: Install dependencies + run: | + apt-get update + apt-get install -y git openssh-client rsync + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - name: Manually checkout env: REPO: '${{ github.repository }}' @@ -43,7 +48,3 @@ jobs: rsync -avz --delete deploy/ ${USERNAME}@${HOST}:${TARGETDIR} --exclude=var # run update script ssh ${USERNAME}@${HOST} /home/c3h-futtern/futtern/update.sh - - - - diff --git a/.junie/guidelines.md b/.junie/guidelines.md new file mode 100644 index 0000000..f0ddfd9 --- /dev/null +++ b/.junie/guidelines.md @@ -0,0 +1,111 @@ +# Development Guidelines for Futtern + +This document provides essential information for developers working on the Futtern project. + +## Build and Configuration + +### PHP Requirements +- PHP 8.4 or higher +- Required extensions: ctype, iconv + +### Database Configuration +- Default: SQLite (`var/data.db`) +- Can be configured for MySQL or PostgreSQL by updating the `DATABASE_URL` in `.env` or `.env.local` + +### Installation Steps +1. Clone the repository +2. Install PHP dependencies: + ```bash + composer install + ``` +3. Install Node.js dependencies: + ```bash + npm install + ``` +4. Copy static assets to Encore directory: + ```bash + mkdir -p assets/css assets/js + cp public/static/css/water.min.css assets/css/ + cp public/static/js/htmx.min.js assets/js/ + ``` +5. Build frontend assets: + ```bash + npm run dev # For development + npm run build # For production + ``` +6. Create database schema: + ```bash + php bin/console doctrine:schema:create + ``` +7. Load fixtures (optional): + ```bash + php bin/console doctrine:fixtures:load + ``` + +### Development Workflow +- Run `npm run watch` to automatically rebuild assets when files change +- Use Symfony CLI for local development: `symfony server:start` + +## Testing + +### Test Configuration +- Tests use Pest PHP (built on PHPUnit) +- Test environment is configured in `.env.test` +- Tests are organized in `tests/Feature` and `tests/Unit` directories + +### Running Tests +- Run all tests: `composer test` +- Run specific tests: `composer test -- --filter=TestName` +- Run tests in parallel: `composer test` (parallel is the default) + +### Test Types +1. **Unit Tests** (`tests/Unit/`): + - Test individual classes in isolation + - Extend `TestCase` or use standalone Pest tests + - Example: + ```php + test('Favicon returns SVG string', function (): void { + $favicon = new Favicon(); + $result = (string)$favicon; + + expect($result) + ->toBeString() + ->toContain('data:image/svg+xml') + ->toContain('transform=\'rotate(') + ->toContain('viewBox=\'0 0 512 512\''); + }) + ->covers(Favicon::class); + ``` + +2. **Feature Tests** (`tests/Feature/`): + - Controller tests: Extend `DbWebTest` for web controllers + - API tests: Extend `DbApiTestCase` for API endpoints + - Each test gets a fresh database + +### Creating New Tests +1. Determine the appropriate test type (Unit or Feature) +2. Create a new test file in the corresponding directory +3. Use Pest's `test()` function to define tests +4. Use `expect()` for assertions +5. Use `->covers()` to specify which classes are covered by the test + +## Code Quality + +### Code Style +- The project uses Easy Coding Standard (ECS) for code style checking +- Configuration is in `ecs.php` +- All classes should be marked as `final` unless they're meant to be extended +- Run code style checks: `composer lint` + +### Code Quality Tools +- Rector is used for automated code refactoring +- Configuration is in `rector.php` +- Run code quality checks: `composer lint` + +### Development Practices +- Use strict types in all PHP files: `toBeString() + ->toContain('data:image/svg+xml') + ->toContain('transform=\'rotate(') + ->toContain('viewBox=\'0 0 512 512\''); +}) + ->covers(Favicon::class); \ No newline at end of file