Download the PHP package thanos-kontos/amock without Composer
On this page you can find all versions of the php package thanos-kontos/amock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thanos-kontos/amock
More information about thanos-kontos/amock
Files in thanos-kontos/amock
Informations about the package amock
Amock - Organize your stub objects in yaml
Release notes
Still not 100% stable. Use with caution
At a glance
Quoting from phpunit:
Sometimes it is just plain hard to test the system under test (SUT) because it depends on other components that cannot be used in the test environment. This could be because they aren't available, they will not return the results needed for the test or because executing them would have undesirable side effects. In other cases, our test strategy requires us to have more control or visibility of the internal behavior of the SUT.
When we are writing a test in which we cannot (or chose not to) use a real depended-on component (DOC), we can replace it with a Test Double. The Test Double doesn't have to behave exactly like the real DOC; it merely has to provide the same API as the real one so that the SUT thinks it is the real one!
It is almost impossible to write good tests without stubbing objects, because we often need to imitate writing to a database or calling an external service.
Amock lets you create these stub objects in yaml instead of "polluting" your tests with irrelevant code.
Instructions
composer require --dev thanos-kontos/amock
Add a directory to store your fixtures e.g. tests/mock_fixtures
and as as many yaml files as you want.
On your test setUp method
or
Then you can use the configured mocks in your tests:
Example
There is an dummy project here that you can use as a reference.
License
Amock is released under the MIT License.