phrity/net-mock
Mocking layer for phrity/net-stream to simplify testing stream-based code. Drop-in compatible stream classes that can log all interactions via any PSR-3 logger and override behavior with callbacks. Includes PHPUnit expectation traits for asserting calls and parameters.
phrity/net-stream while maintaining 1:1 compatibility with the real implementation. Justifies investment if the team uses or plans to adopt phrity/net-stream for networking, file handling, or custom stream abstractions.phrity/net-stream (or plans to) for stream operations (sockets, pipes, custom streams).phrity/net-stream—this package is tightly coupled to its API. Use native PHP mocks or Pest’s HTTP testing instead.ReactPHP, Guzzle). Consider Mockery or PHPUnit’s built-in mocks.*"This package lets us write reliable, fast tests for stream-based features—critical for our [networking/IO-heavy product, e.g., real-time APIs, file processing, or WebSocket services]. By mocking phrity/net-stream, we’ll:
*"This is a drop-in mocking layer for phrity/net-stream that:
hello before closing).RealStreamFactory ↔ MockStreamFactory in one line.phrity/net-stream v1.0–v2.4+.
Proposal: Use this for [specific component, e.g., ‘queue workers’ or ‘HTTP client retries’] to [goal: e.g., ‘ship feature X faster’ or ‘reduce CI noise’]."**"This solves our top CI pain point: stream-related tests failing due to network variability or external dependencies. With this:
*"This integrates natively with Laravel’s ecosystem:
MockStreamFactory for tests, RealStreamFactory for production.ExpectSocketStreamTrait for clean assertions.// config/testing.php
'streams' => [
'factory' => \Phrity\Net\Mock\StreamFactory::class,
],
// Test
$this->expectSocketStreamWrite()->addAssert(fn ($method, $params) =>
$this->assertEquals('data', $params[0])
);
$worker->process(); // Now deterministic!
```"
How can I help you explore Laravel packages today?