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

Phpunit Extras Laravel Package

tarantool/phpunit-extras

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Specialized for Tarantool: The package is tightly coupled with the Tarantool PHP client, making it ideal for projects using Tarantool as a database, cache, or real-time processing layer. It extends rybakit/phpunit-extras with Tarantool-specific annotations (e.g., @lua, @sql, @requires TarantoolVersion), reducing boilerplate for common test scenarios.
  • Modular Design: Leverages traits (TestDoubleClient, RequestExpectations) and base classes (TestCase), allowing incremental adoption. Tests can extend Tarantool\PhpUnit\TestCase or mix in specific traits for targeted functionality.
  • Annotation-Driven: Uses PHPUnit annotations to execute Lua/SQL setup, enforce version requirements, and mock requests/responses. This aligns well with projects using annotations for test configuration (e.g., database migrations, environment-specific tests).

Integration Feasibility

  • Low Friction for Tarantool Users: Requires minimal setup—either extending TestCase or registering the AnnotationExtension in phpunit.xml. Configuration supports DSN strings or environment variables, easing CI/CD integration.
  • Dependency Alignment: Requires tarantool/php (client library) and phpunit (v9+). Composer dev dependencies include ext-msgpack, which is critical for Tarantool’s binary protocol. Check for version conflicts with existing tarantool/php usage (package targets tarantool/php v0.10+).
  • PHP Version Support: Drops PHP 7.1 but supports PHP 8.0+. Ensure your stack meets this requirement.

Technical Risk

  • Limited Adoption: Only 2 stars and 0 dependents suggest niche usage. Validate whether the package’s features (e.g., Lua/SQL annotations) align with your test patterns. Risk of stale maintenance (last release in 2022).
  • Tarantool Version Lock-in: Version constraints (e.g., @requires Tarantool ^2.3.2) may break if your Tarantool server upgrades. Test thoroughly with your target versions.
  • Mocking Complexity: While TestDoubleClient simplifies mocking, advanced scenarios (e.g., custom error responses) require familiarity with the builder pattern. Document edge cases in your test suite.
  • Performance Overhead: Annotations execute Lua/SQL before tests, which could slow down suites if tests are resource-intensive. Profile in CI to identify bottlenecks.

Key Questions

  1. Tarantool Usage: Does your project use Tarantool for critical paths (e.g., caching, real-time data)? If not, the package’s value is limited.
  2. Test Maturity: Are your tests already annotation-heavy? If not, the learning curve for @lua, @sql, etc., may outweigh benefits.
  3. CI/CD Impact: How will Lua/SQL execution before tests affect CI runtime? Test with a sample suite first.
  4. Alternative Tools: Could existing tools (e.g., Pest PHP’s mocking, custom PHPUnit extensions) achieve similar goals with less risk?
  5. Long-Term Support: Given low activity, plan for potential forks or internal maintenance if issues arise.

Integration Approach

Stack Fit

  • Primary Use Case: PHP applications using the Tarantool PHP client (v0.10+) for database/cache interactions.
  • Complementary Tools:
    • PHPUnit: Required (v9+). The package extends PHPUnit’s core with Tarantool-specific assertions.
    • Tarantool Server: Needed for @lua/@sql annotations (unless using mocks). Version constraints must align with your server.
    • Composer: Dev dependency only. No runtime impact.
  • Anti-Patterns: Avoid using this for non-Tarantool PHP tests (e.g., HTTP APIs). Overkill for simple unit tests.

Migration Path

  1. Assessment Phase:
    • Audit existing tests for Tarantool interactions (e.g., client calls, Lua/SQL scripts).
    • Identify repetitive patterns (e.g., manual setup of test data, request mocking).
  2. Pilot Integration:
    • Add the package to a single test file or suite:
      composer require --dev tarantool/phpunit-extras
      
    • Extend Tarantool\PhpUnit\TestCase or add the AnnotationExtension to phpunit.xml.
    • Replace 1–2 manual test setups with annotations (e.g., @sql for schema initialization).
  3. Incremental Adoption:
    • Replace request mocking with TestDoubleClient for isolated tests.
    • Use RequestExpectations to validate interaction counts (e.g., expectSelectRequestToBeCalledOnce()).
    • Gradually migrate to traits (e.g., PreparedStatementExpectations) for complex assertions.
  4. Configuration:
    • Centralize Tarantool connection settings in phpunit.xml using DSN or environment variables:
      <extension class="Tarantool\PhpUnit\Annotation\AnnotationExtension">
        <arguments>
          <string>tcp://%env(TARANTOOL_HOST)%:%env(TARANTOOL_PORT)%</string>
        </arguments>
      </extension>
      
    • Document environment variables (e.g., TARANTOOL_HOST) in your CI/CD pipeline.

Compatibility

  • PHPUnit Version: Tested with PHPUnit 9+. Ensure your project uses a compatible version (check phpunit/phpunit constraints).
  • Tarantool Client: Requires tarantool/php v0.10+. Verify your project’s dependency graph for conflicts.
  • PHP Extensions: Requires ext-msgpack (for binary protocol). Add to composer.json dev requirements if missing:
    "require-dev": {
      "ext-msgpack": "*"
    }
    
  • Tarantool Server: Annotations like @sql require Tarantool 2.0+. Validate server compatibility.

Sequencing

  1. Setup:
    • Install dependencies (composer install).
    • Configure PHPUnit (phpunit.xml or phpunit.neon).
  2. Test Migration:
    • Start with mocking (TestDoubleClient) for tests that don’t need a real Tarantool instance.
    • Use annotations (@lua, @sql) for tests requiring server interactions.
    • Replace manual assertions with expectations (e.g., expectSelectRequestToBeCalledOnce()).
  3. Validation:
    • Run tests locally and in CI to catch annotation/version issues early.
    • Monitor test runtime for performance regressions (Lua/SQL execution overhead).
  4. Documentation:
    • Add a TESTING.md section explaining Tarantool-specific test patterns.
    • Document version constraints (e.g., @requires Tarantool ^2.3.2) and their implications.

Operational Impact

Maintenance

  • Proactive Updates:
    • Monitor the Tarantool PHP client for breaking changes (this package depends on it).
    • Watch for updates to rybakit/phpunit-extras (this package’s base). Subscribe to its release notes.
  • Deprecation Risk:
    • Given low activity, assume the package may stagnate. Plan for forks or internal patches if critical bugs arise.
    • Example: If @sql stops working with Tarantool 3.0, you may need to extend the package or write custom logic.
  • Testing Overhead:
    • Annotations add setup complexity. Balance with the reduction in manual test code. Example:
      // Before (manual)
      public function setUp(): void {
          $this->client->execute('CREATE TABLE test (id INT)')->wait();
      }
      
      // After (annotation)
      /**
       * @sql CREATE TABLE test (id INT)
       */
      public function testTableCreation() { ... }
      

Support

  • Debugging:
    • Tarantool-specific issues may require deep knowledge of the Tarantool protocol or Lua/SQL.
    • Example: If @lua fails silently, check the Tarantool server logs for Lua errors.
  • Community:
  • Fallbacks:
    • For critical tests, maintain manual fallbacks (e.g., skip annotations in CI if Tarantool is unavailable).

Scaling

  • Performance:
    • Lua/SQL Annotations: Executing @lua/@sql before every test can slow down suites. Mitigate by:
      • Using mocks (TestDoubleClient) for non-critical tests.
      • Grouping related tests to reuse setup (e.g., @sql for schema once per class).
    • Mocking: TestDoubleClient is lightweight but may not scale for high-volume request validation. Consider custom
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.
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge