igniphp / framework

Swoole, PSR-15, PSR-7, PSR-11 lightweight modular anti-framework for REST micro-services.
MIT License
265 stars 14 forks source link

Unit testing? #7

Closed mhf-ir closed 6 years ago

mhf-ir commented 6 years ago

Any documentation for test unit ?

dkraczkowski commented 6 years ago

@mhf-ir What do you mean?

mhf-ir commented 6 years ago

if loop run forever how write a sample test unit to create request and mock server dispatch the request and server shutdown after test.

dkraczkowski commented 6 years ago

@mhf-ir Testing server shutdown should be as simple as testing your shutdown event class (the one that extends \Igni\Http\Server\OnShutdown)- you can mockup the \Igni\Http\Server class in your code in order to achieve this.

Testing your controllers should be similar, you simply declare your test class instantiate your controller (which extends HttpController) and mockup Request class.

Entire application layer with the server flow is already tested in the framework so you don't have to worry about that part.

dkraczkowski commented 6 years ago

I can provide example code to help you out.

mhf-ir commented 6 years ago

That's will be awesome, try to using non-block swoole base is new and many developers using Chinease platfroms but it's not documentations well like https://github.com/swoft-cloud/swoft. Documentation and support will be the point.

Thank you for support

dkraczkowski commented 6 years ago

@mhf-ir https://github.com/igniphp/framework/tree/master/docs#testing