thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Middleware trait lazy middleware tests #310

Closed sjokkateer closed 3 years ago

sjokkateer commented 3 years ago

Adds two tests that cover two missing branches of the resolveMiddleware method.

sjokkateer commented 3 years ago

Hello, I initially covered the implementation of the MiddlewareAwareTrait through different setups of the Router class. This would have provided some context on when one or the other branch of the resolveMiddleware would be executed in practice. However, this tightly couples the test to the underlying implementation of the trait which did not feel right.

Because of that I moved to a different approach, testing the trait's functionality directly. This does however make me forward method calls to the trait, if that defeats the purpose of a clean test, or if these tests are too trivial then please don't mind this PR.

philipobenito commented 3 years ago

Thanks @sjokkateer - feel free to increase coverage in other areas too if you like, I'll never be against that