gorghoa / ScenarioStateBehatExtension

Provide a way to share scenario state through steps
MIT License
33 stars 7 forks source link

Is the implemented method argument injection the way to go #8

Closed gorghoa closed 8 years ago

gorghoa commented 8 years ago

As in v1.0.0-rc.1, we hooked into the steps methods injection by replacing (through dependency injection), the original PregMatchArgumentOrganiser.

https://github.com/gorghoa/ScenarioStateBehatExtension/blob/v1.0.0-rc.1/src/ServiceContainer/ScenarioStateExtension.php#L76

Then, we mimic more preg_match captures from the store.

Finally, we call the original PregMatchArgumentOrganiser with our enhanced preg_matchic results…

https://github.com/gorghoa/ScenarioStateBehatExtension/blob/v1.0.0-rc.1/src/ScenarioStateArgumentOrganiser.php#L35

That seem a bit hacky and maybe there is a more intended way to go…

vincentchalamon commented 8 years ago

Better use service decoration, but Behat only supports symfony/dependency-injection 2.1. This feature is from 2.7.

Check https://github.com/Behat/Behat/issues/914 for more infos

Let's add symfony/dependency-injection 2.7 as dependency to your library first, waiting Behat to update its dependencies.

jakzal commented 8 years ago

@vincentchalamon Behat supports any version starting with 2.1 (including the 3.0 branch). It's up to you to force higher version if you need one.

vincentchalamon commented 8 years ago

Yep, that's what I did in composer.json Thanks @jakzal