imbo / behat-api-extension

API extension for Behat, used to ease testing of JSON-based APIs
MIT License
109 stars 42 forks source link

Inject new instance of GuzzleHttp\Client for all contexts #22

Closed christeredvartsen closed 7 years ago

christeredvartsen commented 8 years ago

Today Imbo\BehatApiExtension\Context\Initializer\ApiClientAwareInitializer injects the same instance of the Guzzle HTTP Client into contexts implementing the Imbo\BehatApiExtension\Context\ApiClientAwareContext interface. when it initializes the context. We might not want the same instance all over the place since we can end up changing the handler stack in one test, and this will be carried over to other tests as well.

The initializer is only constructed once, and holds an instance of the client, so this can easily be fixed by injecting a clone of the client for all contexts that implement the said interface.

christeredvartsen commented 7 years ago

Fixed in a33939094d79a583e57577ecd12e31a138bf2403.

christeredvartsen commented 7 years ago

Simply cloning the client does not reset the handler stack, re-opening.

christeredvartsen commented 7 years ago

Resolved by #46.