Download the PHP package tomkyle/mock-psr without Composer
On this page you can find all versions of the php package tomkyle/mock-psr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tomkyle/mock-psr
More information about tomkyle/mock-psr
Files in tomkyle/mock-psr
Package mock-psr
Short Description Traits for mocking common PSR components in PhpUnit tests
License MIT
Informations about the package mock-psr
tomkyle · Mock PSR
Effortless PHPUnit mocks for common PSR interfaces – no more boilerplate, just clean tests.
Installation
Usage
This library provides two ways to use the PSR mocking functionality:
Option 1: Individual Traits
Each PSR standard has its own trait that can be used independently in your test classes:
Option 2: PsrMockFactory (Recommended)
For convenience, use the PsrMockFactory
class which includes all traits and provides access to all mocking methods:
Examples
PSR-7 Messages
PSR-11 Container
Pass an optional array with things the Container has; calling has and get methods will behave like expected, including throwing Psr\Container\NotFoundExceptionInterface
.
PSR-6 Cache
PSR-15 RequestHandler
Includes MockPsr7MessagesTrait
PSR-17 HTTP Factories
Includes MockPsr7MessagesTrait
PSR-18 HTTP Client
Includes MockPsr7MessagesTrait
PDO and PDOStatements
Development
After cloning the repo, install dev dependencies like so:
This package has predefined test setups for code quality, code readability and unit tests. Check them out at the scripts
section of package.json. When working on this library, you basically only need:
All versions of mock-psr with dependencies
psr/log Version ^1.1|^2.0|^3.0
psr/cache Version ^1.0|^2.0|^3.0
psr/container Version ^1.0|^2.0
psr/http-factory Version ^1.0
psr/http-client Version ^1.0
psr/http-message Version ^1.0|^2.0
psr/http-server-handler Version ^1.0
nyholm/psr7 Version ^1.4
phpunit/phpunit Version ^12.0