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

Php Mock Mockery Laravel Package

php-mock/php-mock-mockery

Integrates php-mock with Mockery to mock PHP built-in functions in tests. Create namespaced function mocks with PHPMockery::mock() and set expectations/returns, then call Mockery::close(). Supports only unqualified calls; define early if needed.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

  • Architecture fit: This package is strictly a testing utility, posing no risk to production architecture. It fits well in test suites requiring mocking of non-injectable PHP functions (e.g., time(), file_get_contents()), especially in legacy systems lacking dependency injection.
  • Integration feasibility: Requires minimal Composer setup as a dev dependency. Compatibility with existing PHPUnit/Mockery versions must be verified, but integration typically involves adding a bootstrap hook to configure mocks before tests run.
  • Technical risk: Low adoption (39 stars) and WTFPL license suggest limited community testing. Potential conflicts with other test tools (e.g., global state pollution if mocks aren’t properly isolated). Risk of edge-case failures with PHP 8+ features or extensions (e.g., stream_get_contents()).
  • Key questions:
    • How does it handle PHP 8.1+ native types and attributes in mocked functions?
    • Are there known issues with parallel test execution (e.g., PHPUnit’s --process-isolation)?
    • Does it support mocking functions from PHP extensions (e.g., curl_exec())?

Integration Approach

  • Stack fit: Ideal for projects using PHPUnit and Mockery. Poor fit for non-PHPUnit test frameworks (e.g., Pest, Codeception) unless explicitly compatible.
  • Migration path: Start by adding the package to devDependencies, then update PHPUnit bootstrap to initialize mocks. Gradually replace ad-hoc function mocks in tests with php-mock-mockery syntax (e.g., Mockery::mockFunction('time')->andReturn(123)).
  • Compatibility: Requires Mockery ≥1.3 and PHPUnit ≥9.0. Must validate against existing project versions. Potential conflict if other packages (e.g., mockery/mockery) are already used for class mocking.
  • Sequencing: Integrate early in test setup (e.g., phpunit.xml bootstrap file) to ensure mocks are active before any test code runs. Prioritize high-risk legacy modules first (e.g., date/time-dependent logic).

Operational Impact

  • Maintenance: Low community adoption (39 stars) and WTFPL license indicate high risk for long-term maintenance. Requires internal ownership to address bugs or PHP version incompatibilities. Last release date (2025-03-08
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4