用于 PHP 的模拟、替代和监视器。
No longer maintained
This package is no longer maintained. See this statement for more info.
Mocks, stubs, and spies for PHP.
Available as various Composer packages, depending on the test framework in use:
Eloquent\Phony\Kahlan.Eloquent\Phony\Phpunit.Eloquent\Phony.Eloquent\Phony.See the section on Integration with test frameworks in the [documentation].
Full [documentation] is available.
Phony is a PHP library for creating various kinds of test doubles, including object mocks, function stubs, and function spies.
Phony is committed to supporting new PHP features as they emerge. Features that require workarounds in other mocking frameworks (such as passed-by-reference arguments), typically "just work" with Phony.
Amongst other features, Phony supports:
... tokenIntegrating Phony with your favorite test framework is as simple as choosing the correct namespace to import. Complimentary features make integrations seamless and intuitive:
Interested in better integration with other test frameworks? So are we! Just open a [GitHub issue] if there's something we can do.
Phony has received a great deal of work and refinement where the rubber meets the road; in its verification output:
Phony's output includes succinct but detailed information that is focused on helping you find the cause of the failure as fast as possible. Where appropriate, the output uses difference comparison and color to further highlight important details.
Phony is designed to provide support for testing both object-based, and function-based systems. In Phony, object mocks are built upon full-featured function level stubs and spies.
This focus on support for procedural programming allows Phony to handle many situations that cannot be handled by solely class-based mocking frameworks. Since Phony's class-level support is based upon its function-level support, the interfaces are consistent, and require very little extra knowledge to use.
Phony has an extensive and powerful feature set. For detailed information on a particular feature, select one of the following:
final classesFor help with a difficult testing scenario, questions regarding how to use Phony, or to report issues with Phony itself, please open a [GitHub issue] so that others may benefit from the outcome.
Alternatively, [@ezzatron] may be contacted directly via Twitter.
For detailed usage, see the [documentation].
See the phony-examples repository.
Install the [eloquent/phony] package, then:
use function Eloquent\Phony\mock;
$handle = mock('ClassA');
$handle->methodA->with('argument')->returns('value');
$mock = $handle->get();
assert($mock->methodA('argument') === 'value');
$handle->methodA->calledWith('argu暂无开放 Issues,或尚未同步最近议题。