Micha(el) Bladowski 🇩🇪 🇺🇦
Micha(el) Bladowski 🇩🇪 🇺🇦 @michabbb ·
#PHPUnit Query Count Assertions for #Laravel #PHP #testing #opensource 🧪 Count & assert SQL queries in your tests - catch N+1 problems, full table scans, duplicate queries & slow queries before production ⚡ Assert exact query counts, upper/lower bounds or ranges with closures like assertQueryCountMatches() 🔍 Detect N+1 problems using #Laravel's built-in lazy loading prevention with assertNoLazyLoading() 📊 EXPLAIN-based index analysis detects full table scans, missing indexes, filesort & temporary tables on #MySQL, #MariaDB & #SQLite 🔄 Duplicate query detection finds identical queries executed multiple times with location tracking ⏱️ Query timing assertions for individual query time & total execution time thresholds 🛡️ Combined assertQueriesAreEfficient() checks N+1, duplicates & missing indexes in one call 📋 Detailed failure messages show actual SQL, bindings & source locations 🔧 Configurable thresholds for scan warnings, query cost limits & small table optimization 🧩 Custom analyser support via QueryAnalyser interface for PostgreSQL or other databases 🎯 Works with #PHPUnit setUp() & #Pest beforeEach() including "paranoid mode" 📦 composer require --dev mattiasgeniar/phpunit-query-count-assertions Requires PHP 8.2+, Laravel 11/12, PHPUnit 11 github.com/mattiasgeniar/…
146
Vijay Chauhan
Vijay Chauhan @mr_vijaychauhan ·
🚨 PHPUnit Security Advisory (High severity) CVE-2026-24765 affects PHPUnit code coverage handling via unsafe deserialization in PHPT tests. If you run PHPUnit in CI or locally, this matters. Details and fixes below 👇 #PHP #PHPUnit #SecurityxM
1
197
Micha(el) Bladowski 🇩🇪 🇺🇦
Micha(el) Bladowski 🇩🇪 🇺🇦 @michabbb ·
📋 Eval #Testing #LLM Outputs in #PHPUnit - A comprehensive guide for #PHP developers building #AI applications 🎯 Core problem: Traditional unit tests assert exact outputs, but #LLMs produce probabilistic responses - same prompt yields different wording each time ⚖️ Solution: LLM-as-judge pattern - test behavior not strings. Use a smarter model to evaluate whether responses meet criteria written in plain English 🔄 Multi-turn conversation testing - verify AI behavior over 10+ exchanges, catch persona drift and premature agreement issues 🛡️ Negative tests with data providers - define hard boundaries for things AI should never do: reveal system prompts, acknowledge being AI, break character 📊 Statistical robustness - run tests N times with pass rate thresholds (e.g., 80% of 10 runs must pass) to catch flaky prompts 🔧 Prompt sensitivity testing - verify small phrasing changes don't break behavior (formal vs casual openings) 💰 Cost tracking built-in - use cheap model for conversation, smarter model for judging. Budget alerts at $5/month, run tests nightly not on every commit 🎓 Real catches: character breaks, premature agreement, prompt injection leaks, persona drift in long conversations joshhornby.com/eval-testing-l…
62
Micha(el) Bladowski 🇩🇪 🇺🇦
Micha(el) Bladowski 🇩🇪 🇺🇦 @michabbb ·
#PHPUnit 12.5 released - key features: 🧪 Enhanced parallel testing: Improved worker coordination and resource management for faster test suites #PHP #Testing #PHPDeveloper #TDD 📊 Better failure output: Inline diffs for arrays/objects, clearer stack traces with context 📈 Code coverage: New metrics for line/branch execution, HTML reports with filters 🔍 Mock assertions: `assertMockObjectCreated()` and `assertMockObjectNeverCreated()` ⚙️ Configuration: `cache.result` for result caching, `extensions` for custom listeners 🐛 Bug fixes: Parallel mode stability, Windows path handling, PHAR extraction issues github.com/sebastianbergm…
22