feat: complete Smartgift AI Laravel unit testing toolkit
- Add 10 core testing guides (setup, AAA principles, PHPUnit/Pest, mocking, anti-patterns, PHP 8.4+, debugging, data factories, advanced edge cases) - Add 13 component testing guides covering all Laravel layers - Add standard templates for PHPUnit 10/11 and Pest v2/v3 including ArchitectureTest - Add Docker smart test runner, dependency installer, and CI/CD templates (GitHub Actions, GitLab CI) - Add 4 Claude Code skills (laravel-test-setup, laravel-unit-test with --all mode, laravel-test-review, laravel-mock-helper) - Add single unified installer script (sg-install-unit-testing.sh) with global support, CLI runners, and 1-click updater (sg-test-update) - Add comprehensive documentation (README.md, USAGE-GUIDE.md) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
name: Laravel Unit Tests & Quality Gate
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit Tests (PHP ${{ matrix.php }} - ${{ matrix.dependency-version }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['8.2', '8.3', '8.4']
|
||||
dependency-version: [prefer-stable]
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP & Extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: mbstring, dom, fileinfo, sqlite3, pdo_sqlite, pcov
|
||||
coverage: pcov
|
||||
tools: composer:v2
|
||||
|
||||
- name: Cache Composer Dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-${{ matrix.php }}-
|
||||
|
||||
- name: Install Dependencies
|
||||
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress
|
||||
|
||||
- name: Setup Environment Variables
|
||||
run: |
|
||||
cp .env.example .env.testing 2>/dev/null || true
|
||||
php artisan key:generate --env=testing
|
||||
|
||||
- name: Run Unit Tests (Parallel Execution with Coverage Check)
|
||||
run: |
|
||||
php artisan test --testsuite=Unit --parallel --coverage --min=80
|
||||
env:
|
||||
APP_ENV: testing
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: ":memory:"
|
||||
CACHE_STORE: array
|
||||
QUEUE_CONNECTION: sync
|
||||
MAIL_MAILER: array
|
||||
@@ -0,0 +1,34 @@
|
||||
# GitLab CI/CD Pipeline for Laravel Unit Testing
|
||||
image: php:8.3-cli-alpine
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
variables:
|
||||
APP_ENV: "testing"
|
||||
DB_CONNECTION: "sqlite"
|
||||
DB_DATABASE: ":memory:"
|
||||
CACHE_STORE: "array"
|
||||
QUEUE_CONNECTION: "sync"
|
||||
MAIL_MAILER: "array"
|
||||
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
- vendor/
|
||||
|
||||
unit-test:
|
||||
stage: test
|
||||
before_script:
|
||||
- apk add --no-cache sqlite-libs libzip-dev zip unzip git $PHPIZE_DEPS
|
||||
- pecl install pcov && docker-php-ext-enable pcov
|
||||
- docker-php-ext-install pdo pdo_sqlite zip
|
||||
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
- composer install --prefer-dist --no-progress --no-interaction
|
||||
script:
|
||||
- php artisan test --testsuite=Unit --coverage --min=80
|
||||
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
junit: phpunit-report.xml
|
||||
Reference in New Issue
Block a user