|
| 1 | +# Codecetion-MockServer Helper |
| 2 | +This library is a Module for [Codeception](https://codeception.com/) which allows your tests interact with |
| 3 | +[mock-server](https://www.mock-server.com/)(v5) in an easy and intuitive way. |
| 4 | + |
| 5 | +MockServer allows you to simulate http services in your testing/local environment and this helper allows you check all |
| 6 | +the request you have sent to mock server and manage the expectations of mockserver. |
| 7 | + |
| 8 | +## How to use it |
| 9 | + |
| 10 | +#### WIP |
| 11 | +Write some code examples. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +Install the latest version with |
| 16 | + |
| 17 | +```bash |
| 18 | +$ composer require devizzent/codeception-mockserver-helper --dev |
| 19 | +``` |
| 20 | + |
| 21 | +## Codeception Configuration |
| 22 | +Go to your codeception configuration and add this module |
| 23 | +```yaml |
| 24 | +modules: |
| 25 | + enabled: |
| 26 | + - DEVizzent\CodeceptionMockServerHelper\MockServerHelper: |
| 27 | + ##Mandatory field, mock server url |
| 28 | + url: 'http://mockserver:1080' |
| 29 | + ## Optional field, [test, suite, never] allowed. Default: test |
| 30 | + cleanupBefore: 'test' |
| 31 | + ## Optional field, [enabled, disabled] allowed. Default: enabled |
| 32 | + notMatchedRequest: 'enabled' |
| 33 | +``` |
| 34 | +
|
| 35 | +### cleanupBefore |
| 36 | +
|
| 37 | +This variable set the moment when we want to clean the mockserver logs in order to don't affect the other tests or suites. |
| 38 | +We recomend set this value in the default value. |
| 39 | + - 'test' will remove all logs before start any test making sure that you are not affected by request did in the previous |
| 40 | +test execution. |
| 41 | + - 'suite' will remove all logs before start a suite of tests. |
| 42 | + - 'never' will not remove your mock-server logs. It can generate confusion and failures in your tests, because if |
| 43 | +you check something was called X times, the number of times increase every time you run your tests. If you only check that |
| 44 | +a request was called, it could be called in the previous execution, but by error not in the current one. |
| 45 | +
|
| 46 | +### notMatchedRequest |
| 47 | +
|
| 48 | +When this option is enabled, it creates an expectation with lowest priority which match all the request haven't matched |
| 49 | +our expectations, returning a 500 error with a message `Request not matched by MockServer`. |
| 50 | + |
| 51 | +It allows us to validate all request our application do, are expected and we haven't change our communication with |
| 52 | +external services. |
| 53 | + |
| 54 | +## About |
| 55 | + |
| 56 | +### Requirements |
| 57 | + |
| 58 | +Codecetion-MockServer Helper needs at least php 7.4 or higher and codeception 4 or higher. |
| 59 | + |
| 60 | +### How to contribute |
| 61 | + |
| 62 | +Create an issue describing the bug or the new feature, create your fork of this project and send your PR. |
| 63 | + |
| 64 | +For using the dev environment you only need Docker, Docker-compose and Makefile. |
| 65 | +```text |
| 66 | +Usage: |
| 67 | + make <target> |
| 68 | +
|
| 69 | +Targets: |
| 70 | + help Display this help |
| 71 | + install Install required software and initialize your local configuration |
| 72 | + up Start application containers and required services |
| 73 | + debug Start application containers and required services in debug mode |
| 74 | + down Stop application containers and required services |
| 75 | + test Execute all phpunit test |
| 76 | + composer-update Run composer update |
| 77 | + composer-install Run composer update |
| 78 | +
|
| 79 | +``` |
| 80 | + |
| 81 | +### Author |
| 82 | + |
| 83 | +Vicent Valls - <vizzent@gmail.com> - <https://twitter.com/ViMalaBarraka><https://www.youtube.com/@DEVizzent><br /> |
| 84 | +See also the list of [contributors](https://github.com/DEVizzent/codeception-mockserver-helper/graphs/contributors) who participated in this project. |
| 85 | + |
| 86 | +### License |
| 87 | + |
| 88 | +Codecetion-MockServer Helper is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |
0 commit comments