Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eris Laravel Package

giorgiosironi/eris

Eris brings QuickCheck-style property-based testing to PHP and PHPUnit. Define properties, generate many random inputs, and find minimal counterexamples automatically. Works with PHP 8.1–8.4 and PHPUnit 10–13.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Property-Based Testing (PBT) Paradigm: Eris aligns well with Laravel’s test-driven development (TDD) and quality assurance (QA) practices, particularly for validating edge cases in business logic, API contracts, or data transformations. It complements Laravel’s existing PHPUnit integration without disrupting the ecosystem.
  • Domain-Specific Use Cases:
    • Validation Logic: Ideal for testing Laravel’s form request validators, custom validation rules, or Eloquent model constraints.
    • API Contracts: Useful for verifying API responses (e.g., JSON:API, GraphQL) against generated payloads.
    • Database Interactions: Testing Eloquent queries, mutations, or migrations with randomized data inputs.
    • Cryptographic/Hashing: Validating hashing (e.g., hash(), bcrypt) or encryption logic with adversarial inputs.
  • Laravel-Specific Synergies:
    • Service Container: Eris can be integrated as a test-time dependency (e.g., mocking repositories with randomized data).
    • Artisan Commands: Testing CLI commands with property-based inputs (e.g., php artisan migrate with randomized schema changes).
    • Event Listeners/Jobs: Validating event payloads or queue jobs with generated inputs.

Integration Feasibility

  • PHPUnit Compatibility: Eris supports PHPUnit 10–13, which aligns with Laravel’s latest LTS (Laravel 10+ uses PHPUnit 10+). No conflicts with Laravel’s testing utilities (e.g., RefreshDatabase, MigrateFresh).
  • Composer Dependency: Lightweight (~10MB) and dev-only (--dev), minimizing production impact.
  • Test Isolation: Eris tests run alongside Laravel’s existing test suite without requiring changes to phpunit.xml (beyond adding the trait).
  • CI/CD Fit: Works seamlessly with Laravel’s CI pipelines (GitHub Actions, GitLab CI) since it’s a PHPUnit extension.

Technical Risk

Risk Area Severity Mitigation
Test Flakiness Medium Use shrink() to isolate minimal failing inputs; pair with Laravel’s assertDatabaseHas/assertSoftDeleted.
Performance Overhead Low Eris is optimized for test-time use; disable in production via composer remove.
Generator Complexity Medium Start with simple generators (e.g., Generators::choose(), Generators::string()) before advanced combinators.
Debugging Shrinking Medium Leverage ERIS_ORIGINAL_INPUT=1 env var to inspect failing inputs.
PHPUnit Version Lock Low Laravel 10+ uses PHPUnit 10+, which Eris 1.0+ supports.
Legacy Code Impact Low Eris tests are additive; no breaking changes to existing test suites.

Key Questions for TPM

  1. Prioritization:
    • Which Laravel components (e.g., validation, API, database) would benefit most from PBT?
    • Should Eris be adopted for critical paths (e.g., payment processing) or exploratory testing (e.g., edge-case validation)?
  2. Tooling Integration:
    • Should Eris be wrapped in a custom Laravel facade (e.g., Eris::forAll()) for consistency with Laravel’s syntax?
    • How to integrate with Laravel’s Testing facade (e.g., actingAs(), withoutExceptionHandling)?
  3. Team Adoption:
    • What training is needed for developers to write PBT tests (e.g., generator composition, shrinking)?
    • Should Eris be documented in Laravel’s internal testing guidelines?
  4. CI/CD Strategy:
    • Should Eris tests run in parallel with existing tests (risk: flakiness) or in a dedicated job?
    • How to handle test timeouts for large property spaces (e.g., Generators::date())?
  5. Maintenance:
    • Who will maintain Eris tests (e.g., QA team, developers)?
    • How to balance Eris’s randomness with deterministic Laravel tests (e.g., DatabaseTransactions)?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • PHPUnit: Native integration via TestTrait; no conflicts with Laravel’s TestCase.
    • PestPHP: Eris can be used alongside Pest (via PHPUnit compatibility layer).
    • Dusk/Cypress: Less relevant (PBT is more suited to unit/integration tests).
    • Laravel Mix/Vite: No impact (Eris is server-side).
  • Database:
    • Use Generators::faker() (if extended) or custom generators for Eloquent model attributes.
    • Pair with Laravel’s DatabaseMigrations trait to test schema changes.
  • API Testing:
    • Generate randomized JSON payloads for Http::post() or JsonResponse assertions.
    • Example: Validate API rate-limiting with Generators::choose(1, 1000) requests.

Migration Path

  1. Pilot Phase:
    • Start with 1–2 high-risk components (e.g., payment validation, complex queries).
    • Example: Replace a manual test for User::validatePassword() with:
      public function testPasswordValidation()
      {
          $this->forAll(Generators::string(8, 32))
              ->then(function ($password) {
                  $user = User::factory()->create(['password' => bcrypt('correct_password'));
                  $this->assertFalse($user->validatePassword($password));
              });
      }
      
  2. Incremental Adoption:
    • Add Eris to existing test suites without rewriting tests.
    • Use Generators::oneOf() to combine with existing test data.
  3. Tooling Setup:
    • Add to composer.json:
      "require-dev": {
          "giorgiosironi/eris": "^1.1"
      }
      
    • Extend phpunit.xml with Eris-specific listeners (optional):
      <listeners>
          <listener class="Eris\Listener\LogListener">
              <arguments>
                  <argument value="storage/logs/eris.log"/>
              </arguments>
          </listener>
      </listeners>
      
  4. CI/CD Integration:
    • Add to GitHub Actions:
      - name: Run Eris Tests
        run: php artisan test --filter "ErisTest"
      

Compatibility

Laravel Feature Eris Compatibility Workarounds
Database Transactions ✅ Works with RefreshDatabase/MigrateFresh. Use Generators::date() for timestamped tests.
API Testing (Http::fake()) ✅ Generate randomized routes/payloads. Combine with Laravel’s JsonResponse assertions.
Queues/Jobs ✅ Test job payloads with Generators::array(). Use Generators::faker() for realistic data.
Authentication (actingAs) ✅ Works with Generators::uuid() for user IDs. Pair with Laravel’s actingAs() helper.
File Uploads ⚠️ Limited (use Generators::string() + Storage::fake()). Mock uploads with Generators::binary().
Notifications ✅ Test notification channels with randomized data. Use Generators::email() (custom generator).
Localization (__()) ❌ No direct support. Pre-generate translated strings or use Generators::string().

Sequencing

  1. Phase 1: Foundational Tests
    • Validate core business logic (e.g., pricing calculations, data transformations).
    • Example: Test a DiscountCalculator with randomized input ranges.
  2. Phase 2: API Contracts
    • Generate adversarial JSON payloads to test API validation.
    • Example: Fuzz-test a StoreProductRequest with malformed data.
  3. Phase 3: Database Integrity
    • Test Eloquent constraints (e.g., unique fields, soft deletes).
    • Example: Verify User::email uniqueness with Generators::email().
  4. Phase 4: Edge Cases
    • Stress-test time-sensitive operations (e.g., token expiration, rate limits).
    • Example: Generate Carbon instances for Auth::login() timeouts.

Operational Impact

Maintenance

  • Test Longevity:
    • Eris tests are self-healing (shrinking isolates failures), reducing maintenance overhead.
    • Downside: May require occasional updates if Laravel’s internals change (e.g., new validation rules).
  • Dependency Management:
    • Eris is **MIT-
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony